appium 3.5.2 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/build/lib/appium.d.ts +3 -4
  2. package/build/lib/appium.d.ts.map +1 -1
  3. package/build/lib/appium.js +10 -19
  4. package/build/lib/appium.js.map +1 -1
  5. package/build/lib/bidi-commands.d.ts +2 -2
  6. package/build/lib/bidi-commands.d.ts.map +1 -1
  7. package/build/lib/bidi-commands.js +4 -4
  8. package/build/lib/bidi-commands.js.map +1 -1
  9. package/build/lib/bootstrap/appium-initializer.d.ts.map +1 -1
  10. package/build/lib/bootstrap/appium-initializer.js +12 -16
  11. package/build/lib/bootstrap/appium-initializer.js.map +1 -1
  12. package/build/lib/bootstrap/appium-main-runner.d.ts +1 -1
  13. package/build/lib/bootstrap/appium-main-runner.d.ts.map +1 -1
  14. package/build/lib/bootstrap/appium-main-runner.js +2 -2
  15. package/build/lib/bootstrap/appium-main-runner.js.map +1 -1
  16. package/build/lib/bootstrap/config-file.d.ts +1 -1
  17. package/build/lib/bootstrap/config-file.d.ts.map +1 -1
  18. package/build/lib/bootstrap/config-file.js +13 -15
  19. package/build/lib/bootstrap/config-file.js.map +1 -1
  20. package/build/lib/bootstrap/grid-v3-register.d.ts.map +1 -1
  21. package/build/lib/bootstrap/grid-v3-register.js +7 -14
  22. package/build/lib/bootstrap/grid-v3-register.js.map +1 -1
  23. package/build/lib/bootstrap/init-types.d.ts +1 -1
  24. package/build/lib/bootstrap/init-types.d.ts.map +1 -1
  25. package/build/lib/bootstrap/main-helpers.d.ts +1 -1
  26. package/build/lib/bootstrap/main-helpers.d.ts.map +1 -1
  27. package/build/lib/bootstrap/main-helpers.js +5 -6
  28. package/build/lib/bootstrap/main-helpers.js.map +1 -1
  29. package/build/lib/bootstrap/node-helpers.d.ts +1 -1
  30. package/build/lib/bootstrap/node-helpers.d.ts.map +1 -1
  31. package/build/lib/bootstrap/node-helpers.js +6 -8
  32. package/build/lib/bootstrap/node-helpers.js.map +1 -1
  33. package/build/lib/bootstrap/startup-config.d.ts.map +1 -1
  34. package/build/lib/bootstrap/startup-config.js.map +1 -1
  35. package/build/lib/cli/args.d.ts +2 -4
  36. package/build/lib/cli/args.d.ts.map +1 -1
  37. package/build/lib/cli/args.js +3 -6
  38. package/build/lib/cli/args.js.map +1 -1
  39. package/build/lib/cli/driver-command.d.ts +2 -2
  40. package/build/lib/cli/driver-command.d.ts.map +1 -1
  41. package/build/lib/cli/driver-command.js +4 -7
  42. package/build/lib/cli/driver-command.js.map +1 -1
  43. package/build/lib/cli/extension-command.d.ts +3 -20
  44. package/build/lib/cli/extension-command.d.ts.map +1 -1
  45. package/build/lib/cli/extension-command.js +32 -56
  46. package/build/lib/cli/extension-command.js.map +1 -1
  47. package/build/lib/cli/extension.d.ts.map +1 -1
  48. package/build/lib/cli/extension.js.map +1 -1
  49. package/build/lib/cli/parser.d.ts.map +1 -1
  50. package/build/lib/cli/parser.js +10 -15
  51. package/build/lib/cli/parser.js.map +1 -1
  52. package/build/lib/cli/plugin-command.d.ts +2 -2
  53. package/build/lib/cli/plugin-command.d.ts.map +1 -1
  54. package/build/lib/cli/plugin-command.js +4 -7
  55. package/build/lib/cli/plugin-command.js.map +1 -1
  56. package/build/lib/cli/setup-command.d.ts.map +1 -1
  57. package/build/lib/cli/setup-command.js +2 -2
  58. package/build/lib/cli/setup-command.js.map +1 -1
  59. package/build/lib/cli/utils.d.ts.map +1 -1
  60. package/build/lib/cli/utils.js.map +1 -1
  61. package/build/lib/doctor/doctor.d.ts.map +1 -1
  62. package/build/lib/doctor/doctor.js +1 -4
  63. package/build/lib/doctor/doctor.js.map +1 -1
  64. package/build/lib/extension/driver-config.d.ts +1 -1
  65. package/build/lib/extension/driver-config.d.ts.map +1 -1
  66. package/build/lib/extension/driver-config.js +2 -4
  67. package/build/lib/extension/driver-config.js.map +1 -1
  68. package/build/lib/extension/extension-config.d.ts +1 -1
  69. package/build/lib/extension/extension-config.d.ts.map +1 -1
  70. package/build/lib/extension/extension-config.js +10 -10
  71. package/build/lib/extension/extension-config.js.map +1 -1
  72. package/build/lib/extension/index.d.ts.map +1 -1
  73. package/build/lib/extension/index.js +3 -5
  74. package/build/lib/extension/index.js.map +1 -1
  75. package/build/lib/extension/manifest-migrations.d.ts.map +1 -1
  76. package/build/lib/extension/manifest-migrations.js.map +1 -1
  77. package/build/lib/extension/manifest.d.ts.map +1 -1
  78. package/build/lib/extension/manifest.js +2 -2
  79. package/build/lib/extension/manifest.js.map +1 -1
  80. package/build/lib/extension/plugin-config.d.ts.map +1 -1
  81. package/build/lib/extension/plugin-config.js +1 -2
  82. package/build/lib/extension/plugin-config.js.map +1 -1
  83. package/build/lib/helpers/build.d.ts.map +1 -1
  84. package/build/lib/helpers/build.js +1 -1
  85. package/build/lib/helpers/build.js.map +1 -1
  86. package/build/lib/helpers/capability.d.ts.map +1 -1
  87. package/build/lib/helpers/capability.js +2 -4
  88. package/build/lib/helpers/capability.js.map +1 -1
  89. package/build/lib/helpers/network.d.ts.map +1 -1
  90. package/build/lib/helpers/network.js +1 -3
  91. package/build/lib/helpers/network.js.map +1 -1
  92. package/build/lib/insecure-features.d.ts +1 -1
  93. package/build/lib/insecure-features.d.ts.map +1 -1
  94. package/build/lib/insecure-features.js +2 -6
  95. package/build/lib/insecure-features.js.map +1 -1
  96. package/build/lib/inspector-commands.d.ts.map +1 -1
  97. package/build/lib/inspector-commands.js +6 -16
  98. package/build/lib/inspector-commands.js.map +1 -1
  99. package/build/lib/logsink.d.ts.map +1 -1
  100. package/build/lib/logsink.js +5 -9
  101. package/build/lib/logsink.js.map +1 -1
  102. package/build/lib/main.d.ts.map +1 -1
  103. package/build/lib/main.js.map +1 -1
  104. package/build/lib/schema/arg-spec.d.ts.map +1 -1
  105. package/build/lib/schema/arg-spec.js.map +1 -1
  106. package/build/lib/schema/cli-args-guards.d.ts +1 -1
  107. package/build/lib/schema/cli-args-guards.d.ts.map +1 -1
  108. package/build/lib/schema/cli-args-guards.js.map +1 -1
  109. package/build/lib/schema/cli-args.d.ts.map +1 -1
  110. package/build/lib/schema/cli-args.js +2 -2
  111. package/build/lib/schema/cli-args.js.map +1 -1
  112. package/build/lib/schema/cli-transformers.d.ts.map +1 -1
  113. package/build/lib/schema/cli-transformers.js +2 -4
  114. package/build/lib/schema/cli-transformers.js.map +1 -1
  115. package/build/lib/schema/format-errors.d.ts +1 -1
  116. package/build/lib/schema/format-errors.d.ts.map +1 -1
  117. package/build/lib/schema/format-errors.js.map +1 -1
  118. package/build/lib/schema/index.d.ts +2 -2
  119. package/build/lib/schema/index.d.ts.map +1 -1
  120. package/build/lib/schema/index.js +2 -2
  121. package/build/lib/schema/index.js.map +1 -1
  122. package/build/lib/schema/keywords.d.ts.map +1 -1
  123. package/build/lib/schema/keywords.js.map +1 -1
  124. package/build/lib/schema/schema.d.ts +1 -1
  125. package/build/lib/schema/schema.d.ts.map +1 -1
  126. package/build/lib/schema/schema.js +5 -7
  127. package/build/lib/schema/schema.js.map +1 -1
  128. package/build/lib/utils/index.d.ts +2 -2
  129. package/build/lib/utils/index.d.ts.map +1 -1
  130. package/build/lib/utils/index.js +8 -8
  131. package/build/lib/utils/index.js.map +1 -1
  132. package/build/lib/utils/is-package-changed.d.ts.map +1 -1
  133. package/build/lib/utils/is-package-changed.js +2 -4
  134. package/build/lib/utils/is-package-changed.js.map +1 -1
  135. package/build/lib/utils/object.d.ts.map +1 -1
  136. package/build/lib/utils/object.js +1 -3
  137. package/build/lib/utils/object.js.map +1 -1
  138. package/build/lib/utils/package-changed.d.ts +0 -1
  139. package/build/lib/utils/package-changed.d.ts.map +1 -1
  140. package/build/lib/utils/package-changed.js +4 -3
  141. package/build/lib/utils/package-changed.js.map +1 -1
  142. package/build/lib/utils/package-json.d.ts.map +1 -1
  143. package/build/lib/utils/package-json.js.map +1 -1
  144. package/build/lib/utils/resolve-from.d.ts.map +1 -1
  145. package/build/lib/utils/resolve-from.js.map +1 -1
  146. package/build/types/cli.d.ts.map +1 -1
  147. package/build/types/index.d.ts +2 -2
  148. package/build/types/index.d.ts.map +1 -1
  149. package/build/types/index.js +1 -1
  150. package/build/types/index.js.map +1 -1
  151. package/build/types/manifest/base.d.ts.map +1 -1
  152. package/build/types/manifest/v3.d.ts.map +1 -1
  153. package/build/types/manifest/v4.d.ts.map +1 -1
  154. package/lib/appium.ts +46 -94
  155. package/lib/bidi-commands.ts +28 -63
  156. package/lib/bootstrap/appium-initializer.ts +26 -38
  157. package/lib/bootstrap/appium-main-runner.ts +14 -32
  158. package/lib/bootstrap/config-file.ts +19 -37
  159. package/lib/bootstrap/grid-v3-register.ts +12 -38
  160. package/lib/bootstrap/init-types.ts +3 -5
  161. package/lib/bootstrap/main-helpers.ts +15 -25
  162. package/lib/bootstrap/node-helpers.ts +11 -22
  163. package/lib/bootstrap/startup-config.ts +13 -18
  164. package/lib/cli/args.ts +9 -18
  165. package/lib/cli/driver-command.ts +6 -13
  166. package/lib/cli/extension-command.ts +55 -156
  167. package/lib/cli/extension.ts +6 -5
  168. package/lib/cli/parser.ts +23 -29
  169. package/lib/cli/plugin-command.ts +7 -17
  170. package/lib/cli/setup-command.ts +10 -28
  171. package/lib/cli/utils.ts +1 -5
  172. package/lib/doctor/doctor.ts +1 -4
  173. package/lib/extension/driver-config.ts +5 -15
  174. package/lib/extension/extension-config.ts +36 -80
  175. package/lib/extension/index.ts +16 -31
  176. package/lib/extension/manifest-migrations.ts +1 -0
  177. package/lib/extension/manifest.ts +9 -19
  178. package/lib/extension/plugin-config.ts +5 -12
  179. package/lib/helpers/build.ts +4 -6
  180. package/lib/helpers/capability.ts +6 -17
  181. package/lib/helpers/network.ts +2 -6
  182. package/lib/insecure-features.ts +7 -22
  183. package/lib/inspector-commands.ts +28 -68
  184. package/lib/logsink.ts +11 -25
  185. package/lib/main.ts +2 -7
  186. package/lib/schema/arg-spec.ts +1 -0
  187. package/lib/schema/cli-args-guards.ts +7 -14
  188. package/lib/schema/cli-args.ts +10 -17
  189. package/lib/schema/cli-transformers.ts +5 -10
  190. package/lib/schema/format-errors.ts +2 -1
  191. package/lib/schema/index.ts +2 -2
  192. package/lib/schema/keywords.ts +2 -2
  193. package/lib/schema/schema.ts +14 -33
  194. package/lib/utils/index.ts +3 -3
  195. package/lib/utils/is-package-changed.ts +4 -7
  196. package/lib/utils/object.ts +4 -13
  197. package/lib/utils/package-changed.ts +7 -9
  198. package/lib/utils/package-json.ts +2 -3
  199. package/lib/utils/resolve-from.ts +1 -4
  200. package/package.json +32 -31
  201. package/scripts/autoinstall-extensions.js +1 -4
  202. package/tsconfig.json +7 -11
  203. package/types/cli.ts +2 -3
  204. package/types/index.ts +2 -2
  205. package/types/manifest/base.ts +3 -10
  206. package/types/manifest/v3.ts +3 -10
  207. package/types/manifest/v4.ts +3 -10
  208. package/LICENSE +0 -201
@@ -1,6 +1,8 @@
1
1
  import {console, util} from '@appium/support';
2
2
  import type {ExtMetadata, ExtRecord, InstallType} from 'appium/types';
3
- import ExtensionCliCommand from './extension-command';
3
+
4
+ import {KNOWN_PLUGINS} 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_PLUGINS} from '../constants';
12
13
 
13
14
  const REQ_PLUGIN_FIELDS = ['pluginName', 'mainClass'];
14
15
  type PluginInstallOpts = {plugin: string; installType: InstallType; packageName?: string};
@@ -28,11 +29,7 @@ export default class PluginCliCommand extends ExtensionCliCommand<'plugin'> {
28
29
  *
29
30
  * @param opts - install options
30
31
  */
31
- async install({
32
- plugin,
33
- installType,
34
- packageName,
35
- }: PluginInstallOpts): Promise<ExtRecord<'plugin'>> {
32
+ async install({plugin, installType, packageName}: PluginInstallOpts): Promise<ExtRecord<'plugin'>> {
36
33
  return await super._install({
37
34
  installSpec: plugin,
38
35
  installType,
@@ -93,10 +90,7 @@ export default class PluginCliCommand extends ExtensionCliCommand<'plugin'> {
93
90
  * @returns formatted success text
94
91
  */
95
92
  override getPostInstallText({extName, extData}: ExtensionArgs<'plugin'>): PostInstallText {
96
- return console.styleText(
97
- 'green',
98
- `Plugin ${extName}@${extData.version} successfully installed`,
99
- );
93
+ return console.styleText('green', `Plugin ${extName}@${extData.version} successfully installed`);
100
94
  }
101
95
 
102
96
  /**
@@ -108,13 +102,9 @@ export default class PluginCliCommand extends ExtensionCliCommand<'plugin'> {
108
102
  * @param pluginMetadata - `appium` metadata from extension package
109
103
  * @param installSpec - install spec from CLI
110
104
  */
111
- override validateExtensionFields(
112
- pluginMetadata: ExtMetadata<'plugin'>,
113
- installSpec: string,
114
- ): void {
105
+ override validateExtensionFields(pluginMetadata: ExtMetadata<'plugin'>, installSpec: string): void {
115
106
  const missingFields = REQ_PLUGIN_FIELDS.reduce<string[]>(
116
- (acc, field) =>
117
- pluginMetadata[field as keyof typeof pluginMetadata] ? acc : [...acc, field],
107
+ (acc, field) => (pluginMetadata[field as keyof typeof pluginMetadata] ? acc : [...acc, field]),
118
108
  [],
119
109
  );
120
110
 
@@ -1,3 +1,4 @@
1
+ import {fs, system} from '@appium/support';
1
2
  import type {
2
3
  Args,
3
4
  CliCommandSetup,
@@ -5,11 +6,11 @@ import type {
5
6
  CliExtensionCommand,
6
7
  CliExtensionSubcommand,
7
8
  } from 'appium/types';
9
+
8
10
  import {DESKTOP_BROWSERS, DESKTOP_DRIVERS, MOBILE_DRIVERS} from '../constants';
9
- import {runExtensionCommand} from './extension';
10
- import {system, fs} from '@appium/support';
11
- import {log} from '../logger';
12
11
  import type {ExtensionConfig} from '../extension/extension-config';
12
+ import {log} from '../logger';
13
+ import {runExtensionCommand} from './extension';
13
14
 
14
15
  /**
15
16
  * Subcommands of preset for setup
@@ -44,9 +45,7 @@ type CliExtArgs = Args<CliExtensionCommand, CliExtensionSubcommand>;
44
45
  /**
45
46
  * Return a list of drivers available for current host platform.
46
47
  */
47
- export function getPresetDrivers(
48
- presetName: Exclude<CliCommandSetupSubcommand, 'reset'>,
49
- ): string[] {
48
+ export function getPresetDrivers(presetName: Exclude<CliCommandSetupSubcommand, 'reset'>): string[] {
50
49
  return PRESET_PAIRS[presetName].filter((driver) => {
51
50
  if (DRIVERS_ONLY_MACOS.includes(driver)) {
52
51
  return system.isMac();
@@ -105,10 +104,7 @@ export async function runSetupCommand(
105
104
  /**
106
105
  * Resets all installed drivers and extensions
107
106
  */
108
- async function resetAllExtensions(
109
- driverConfig: DriverConfig,
110
- pluginConfig: PluginConfig,
111
- ): Promise<void> {
107
+ async function resetAllExtensions(driverConfig: DriverConfig, pluginConfig: PluginConfig): Promise<void> {
112
108
  const commandConfigs: [CliExtensionCommand, DriverConfig | PluginConfig][] = [
113
109
  ['driver', driverConfig],
114
110
  ['plugin', pluginConfig],
@@ -116,11 +112,7 @@ async function resetAllExtensions(
116
112
  for (const [command, config] of commandConfigs) {
117
113
  for (const extensionName of Object.keys(config.installedExtensions)) {
118
114
  try {
119
- await uninstallExtension(
120
- extensionName,
121
- extensionCommandArgs(command, extensionName, 'uninstall'),
122
- config,
123
- );
115
+ await uninstallExtension(extensionName, extensionCommandArgs(command, extensionName, 'uninstall'), config);
124
116
  } catch (e) {
125
117
  log.warn(
126
118
  `${extensionName} ${command} cannot be uninstalled. Will delete the manifest anyway. ` +
@@ -136,9 +128,7 @@ async function resetAllExtensions(
136
128
 
137
129
  await fs.rimraf(manifestPath);
138
130
  if (await fs.exists(manifestPath)) {
139
- throw new Error(
140
- `${command} manifest at '${manifestPath}' cannot be deleted. Is it accessible?`,
141
- );
131
+ throw new Error(`${command} manifest at '${manifestPath}' cannot be deleted. Is it accessible?`);
142
132
  } else {
143
133
  log.info(`Successfully deleted ${command} manifest at '${manifestPath}'`);
144
134
  }
@@ -174,11 +164,7 @@ async function installDrivers(
174
164
  driverConfig: DriverConfig,
175
165
  ): Promise<void> {
176
166
  for (const driverName of getPresetDrivers(subcommand)) {
177
- await installExtension(
178
- driverName,
179
- extensionCommandArgs('driver', driverName, 'install'),
180
- driverConfig,
181
- );
167
+ await installExtension(driverName, extensionCommandArgs('driver', driverName, 'install'), driverConfig);
182
168
  }
183
169
  }
184
170
 
@@ -187,11 +173,7 @@ async function installDrivers(
187
173
  */
188
174
  async function setupDefaultPlugins(pluginConfig: PluginConfig): Promise<void> {
189
175
  for (const pluginName of DEFAULT_PLUGINS) {
190
- await installExtension(
191
- pluginName,
192
- extensionCommandArgs('plugin', pluginName, 'install'),
193
- pluginConfig,
194
- );
176
+ await installExtension(pluginName, extensionCommandArgs('plugin', pluginName, 'install'), pluginConfig);
195
177
  }
196
178
  }
197
179
 
package/lib/cli/utils.ts CHANGED
@@ -78,11 +78,7 @@ export function log(json: boolean, msg: string): void {
78
78
  * @param fn - function to wrap with spinning
79
79
  * @returns result of `fn`
80
80
  */
81
- export async function spinWith<T>(
82
- json: boolean,
83
- msg: string,
84
- fn: () => T | Promise<T>,
85
- ): Promise<T> {
81
+ export async function spinWith<T>(json: boolean, msg: string, fn: () => T | Promise<T>): Promise<T> {
86
82
  if (json) {
87
83
  return await fn();
88
84
  }
@@ -123,10 +123,7 @@ export class Doctor {
123
123
  manualIssues,
124
124
  );
125
125
  await handleIssues(
126
- [
127
- '### Optional Manual Fixes ###',
128
- 'To fix these optional issues, please do the following manually:',
129
- ],
126
+ ['### Optional Manual Fixes ###', 'To fix these optional issues, please do the following manually:'],
130
127
  manualIssuesOptional,
131
128
  );
132
129
 
@@ -1,6 +1,7 @@
1
1
  import {util} from '@appium/support';
2
2
  import type {DriverClass, DriverType, StringRecord} from '@appium/types';
3
3
  import type {ExtManifest, ExtName, ExtRecord} from 'appium/types';
4
+
4
5
  import {DRIVER_TYPE} from '../constants';
5
6
  import {log} from '../logger';
6
7
  import type {ExtManifestProblem} from './extension-config';
@@ -48,10 +49,7 @@ export class DriverConfig extends ExtensionConfig<DriverType> {
48
49
  return `${String(driverName)}@${version} (automationName '${automationName}')`;
49
50
  }
50
51
 
51
- async findMatchingDriver<C extends StringRecord>({
52
- automationName,
53
- platformName,
54
- }: C): Promise<MatchedDriver> {
52
+ async findMatchingDriver<C extends StringRecord>({automationName, platformName}: C): Promise<MatchedDriver> {
55
53
  if (typeof platformName !== 'string') {
56
54
  throw new Error('You must include a platformName capability');
57
55
  }
@@ -66,10 +64,7 @@ export class DriverConfig extends ExtensionConfig<DriverType> {
66
64
  );
67
65
 
68
66
  try {
69
- const {driverName, mainClass, version} = this._getDriverBySupport(
70
- automationName,
71
- platformName,
72
- );
67
+ const {driverName, mainClass, version} = this._getDriverBySupport(automationName, platformName);
73
68
  log.info(`The '${driverName}' driver was installed and matched caps.`);
74
69
  log.info(`Will require it at ${this.getInstallPath(driverName)}`);
75
70
  const driver = await this.requireAsync(driverName as ExtName<DriverType>);
@@ -90,10 +85,7 @@ export class DriverConfig extends ExtensionConfig<DriverType> {
90
85
  }
91
86
  }
92
87
 
93
- protected override getConfigProblems(
94
- extManifest: ExtManifest<DriverType>,
95
- extName: string,
96
- ): ExtManifestProblem[] {
88
+ protected override getConfigProblems(extManifest: ExtManifest<DriverType>, extName: string): ExtManifestProblem[] {
97
89
  void extName;
98
90
  const problems: ExtManifestProblem[] = [];
99
91
  const {platformNames, automationName} = extManifest;
@@ -146,9 +138,7 @@ export class DriverConfig extends ExtensionConfig<DriverType> {
146
138
  for (const [driverName, driverData] of Object.entries(drivers)) {
147
139
  const {automationName, platformNames} = driverData;
148
140
  const aNameMatches = automationName.toLowerCase() === matchAutomationName.toLowerCase();
149
- const pNameMatches = platformNames
150
- .map((p) => p.toLowerCase())
151
- .includes(matchPlatformName.toLowerCase());
141
+ const pNameMatches = platformNames.map((p) => p.toLowerCase()).includes(matchPlatformName.toLowerCase());
152
142
 
153
143
  if (aNameMatches && pNameMatches) {
154
144
  return {driverName, ...driverData};
@@ -1,25 +1,22 @@
1
- import type {ExtensionType} from '@appium/types';
2
- import type {ExtClass, ExtManifest, ExtName, ExtRecord, InstallType} from 'appium/types';
3
- import type {SchemaObject} from 'ajv';
4
- import {util, fs, system} from '@appium/support';
5
1
  import path from 'node:path';
6
- import {capitalize, resolveFrom} from '../utils';
7
2
  import {pathToFileURL} from 'node:url';
3
+
4
+ import {fs, system, util} from '@appium/support';
5
+ import type {ExtensionType, StringRecord} from '@appium/types';
6
+ import type {SchemaObject} from 'ajv';
7
+ import type {ExtClass, ExtManifest, ExtName, ExtRecord, InstallType} from 'appium/types';
8
8
  import {satisfies} from 'semver';
9
- import {commandClasses} from '../cli/extension';
9
+
10
10
  import type {
11
11
  ExtensionList,
12
12
  ExtensionListData,
13
13
  InstalledExtensionListData,
14
+ ExtensionCliCommand,
14
15
  } from '../cli/extension-command';
15
- import type {ExtCommand} from '../cli/extension';
16
16
  import {APPIUM_VER} from '../helpers/build';
17
17
  import {log} from '../logger';
18
- import {
19
- ALLOWED_SCHEMA_EXTENSIONS,
20
- isAllowedSchemaFileExtension,
21
- registerSchema,
22
- } from '../schema/schema';
18
+ import {ALLOWED_SCHEMA_EXTENSIONS, isAllowedSchemaFileExtension, registerSchema} from '../schema/schema';
19
+ import {capitalize, resolveFrom} from '../utils';
23
20
  import type {Manifest} from './manifest';
24
21
 
25
22
  const DEFAULT_ENTRY_POINT = 'index.js';
@@ -138,10 +135,7 @@ export abstract class ExtensionConfig<ExtType extends ExtensionType> {
138
135
  * @param extName - Extension key as stored in the manifest
139
136
  * @param extManifest - Manifest entry for that extension
140
137
  */
141
- async getProblems(
142
- extName: string,
143
- extManifest: ExtManifest<ExtType>,
144
- ): Promise<ExtManifestProblem[]> {
138
+ async getProblems(extName: string, extManifest: ExtManifest<ExtType>): Promise<ExtManifestProblem[]> {
145
139
  return [
146
140
  ...this.getGenericConfigProblems(extManifest, extName),
147
141
  ...this.getConfigProblems(extManifest, extName),
@@ -182,15 +176,10 @@ export abstract class ExtensionConfig<ExtType extends ExtensionType> {
182
176
  }
183
177
  // remove this extension from the list since it's not valid
184
178
  errorSummaries.push(
185
- `${this.extensionType} "${extName}" had ${util.pluralize(
186
- 'error',
187
- problems.length,
188
- )} and will not be available:`,
179
+ `${this.extensionType} "${extName}" had ${util.pluralize('error', problems.length)} and will not be available:`,
189
180
  );
190
181
  for (const problem of problems) {
191
- errorSummaries.push(
192
- ` - ${problem.err} (Actual value: ` + `${JSON.stringify(problem.val)})`,
193
- );
182
+ errorSummaries.push(` - ${problem.err} (Actual value: ` + `${JSON.stringify(problem.val)})`);
194
183
  }
195
184
  }
196
185
  const warningSummaries: string[] = [];
@@ -258,10 +247,7 @@ export abstract class ExtensionConfig<ExtType extends ExtensionType> {
258
247
  *
259
248
  * Pass `{ write: false }` to defer flushing until a later manifest write.
260
249
  */
261
- async removeExtension(
262
- extName: ExtName<ExtType>,
263
- {write = true}: ExtensionConfigMutationOpts = {},
264
- ): Promise<void> {
250
+ async removeExtension(extName: ExtName<ExtType>, {write = true}: ExtensionConfigMutationOpts = {}): Promise<void> {
265
251
  this.manifest.deleteExtension(this.extensionType, extName);
266
252
  if (write) {
267
253
  await this.manifest.write();
@@ -336,19 +322,11 @@ export abstract class ExtensionConfig<ExtType extends ExtensionType> {
336
322
  extName: string,
337
323
  extManifest: ExtManifestWithSchema<ExtType>,
338
324
  ): Promise<SchemaObject | undefined> {
339
- return await ExtensionConfig._readExtensionSchema(
340
- this.appiumHome,
341
- this.extensionType,
342
- extName,
343
- extManifest,
344
- );
325
+ return await ExtensionConfig._readExtensionSchema(this.appiumHome, this.extensionType, extName, extManifest);
345
326
  }
346
327
 
347
328
  /** Optional async warnings for this extension kind; override in subclasses when needed. */
348
- protected async getConfigWarnings(
349
- _extManifest: ExtManifest<ExtType>,
350
- _extName: string,
351
- ): Promise<string[]> {
329
+ protected async getConfigWarnings(_extManifest: ExtManifest<ExtType>, _extName: string): Promise<string[]> {
352
330
  void _extManifest;
353
331
  void _extName;
354
332
  return [];
@@ -374,16 +352,15 @@ export abstract class ExtensionConfig<ExtType extends ExtensionType> {
374
352
  warningMap.set(extName, warnings);
375
353
  }
376
354
 
377
- const {errorSummaries, warningSummaries} = this.getValidationResultSummaries(
378
- errorMap,
379
- warningMap,
380
- );
355
+ const {errorSummaries, warningSummaries} = this.getValidationResultSummaries(errorMap, warningMap);
381
356
 
382
357
  if (!util.isEmpty(errorSummaries)) {
383
358
  log.error(
384
- `Appium encountered ${util.pluralize('error', errorMap.size, true)} while validating ${
385
- this.extensionType
386
- }s found in manifest ${this.manifestPath}`,
359
+ `Appium encountered ${util.pluralize(
360
+ 'error',
361
+ errorMap.size,
362
+ true,
363
+ )} while validating ${this.extensionType}s found in manifest ${this.manifestPath}`,
387
364
  );
388
365
  for (const summary of errorSummaries) {
389
366
  log.error(summary);
@@ -411,8 +388,10 @@ export abstract class ExtensionConfig<ExtType extends ExtensionType> {
411
388
  if (this.#listDataCache) {
412
389
  return this.#listDataCache;
413
390
  }
414
- const CommandClass = commandClasses[this.extensionType] as ExtCommand<ExtType>;
415
- const cmd = new CommandClass({config: this, json: true});
391
+ // Import here to avoid circular dependency with cli/extension
392
+ const {commandClasses} = await import('../cli/extension.js');
393
+ const CommandClass = (commandClasses as StringRecord)[this.extensionType];
394
+ const cmd = new CommandClass({config: this, json: true}) as ExtensionCliCommand<ExtType>;
416
395
  const listData = await cmd.list({showInstalled: true, showUpdates: true});
417
396
  this.#listDataCache = listData;
418
397
  return listData;
@@ -421,10 +400,7 @@ export abstract class ExtensionConfig<ExtType extends ExtensionType> {
421
400
  /**
422
401
  * Warnings about manifest install fields and Appium peer dependency compatibility for one extension.
423
402
  */
424
- protected async getGenericConfigWarnings(
425
- extManifest: ExtManifest<ExtType>,
426
- extName: string,
427
- ): Promise<string[]> {
403
+ protected async getGenericConfigWarnings(extManifest: ExtManifest<ExtType>, extName: string): Promise<string[]> {
428
404
  const {appiumVersion, installSpec, installType, pkgName} = extManifest;
429
405
  const warnings: string[] = [];
430
406
 
@@ -440,11 +416,7 @@ export abstract class ExtensionConfig<ExtType extends ExtensionType> {
440
416
  const extTypeText = capitalize(this.extensionType);
441
417
 
442
418
  if (invalidFields.length) {
443
- const invalidFieldsEnumerationText = util.pluralize(
444
- 'invalid or missing field',
445
- invalidFields.length,
446
- true,
447
- );
419
+ const invalidFieldsEnumerationText = util.pluralize('invalid or missing field', invalidFields.length, true);
448
420
  const invalidFieldsText = invalidFields.map((field) => `"${field}"`).join(', ');
449
421
 
450
422
  warnings.push(
@@ -499,10 +471,7 @@ export abstract class ExtensionConfig<ExtType extends ExtensionType> {
499
471
  }
500
472
 
501
473
  /** Validates and registers extension CLI/config schema when the manifest defines a `schema` field. */
502
- protected async getSchemaProblems(
503
- extManifest: ExtManifest<ExtType>,
504
- extName: string,
505
- ): Promise<ExtManifestProblem[]> {
474
+ protected async getSchemaProblems(extManifest: ExtManifest<ExtType>, extName: string): Promise<ExtManifestProblem[]> {
506
475
  const problems: ExtManifestProblem[] = [];
507
476
  const {schema: argSchemaPath} = extManifest;
508
477
  if (ExtensionConfig.extDataHasSchema(extManifest)) {
@@ -518,9 +487,7 @@ export abstract class ExtensionConfig<ExtType extends ExtensionType> {
518
487
  }
519
488
  } else {
520
489
  problems.push({
521
- err: `Schema file has unsupported extension. Allowed: ${[
522
- ...ALLOWED_SCHEMA_EXTENSIONS,
523
- ].join(', ')}`,
490
+ err: `Schema file has unsupported extension. Allowed: ${[...ALLOWED_SCHEMA_EXTENSIONS].join(', ')}`,
524
491
  val: argSchemaPath,
525
492
  });
526
493
  }
@@ -544,10 +511,7 @@ export abstract class ExtensionConfig<ExtType extends ExtensionType> {
544
511
  }
545
512
 
546
513
  /** Blocking issues for required manifest fields shared by all extensions (version, package name, main class). */
547
- protected getGenericConfigProblems(
548
- extManifest: ExtManifest<ExtType>,
549
- extName: string,
550
- ): ExtManifestProblem[] {
514
+ protected getGenericConfigProblems(extManifest: ExtManifest<ExtType>, extName: string): ExtManifestProblem[] {
551
515
  void extName;
552
516
  const {version, pkgName, mainClass} = extManifest;
553
517
  const problems: ExtManifestProblem[] = [];
@@ -577,10 +541,7 @@ export abstract class ExtensionConfig<ExtType extends ExtensionType> {
577
541
  }
578
542
 
579
543
  /** Driver- or plugin-specific blocking validation; override in subclasses when needed. */
580
- protected getConfigProblems(
581
- _extManifest: ExtManifest<ExtType>,
582
- _extName: string,
583
- ): ExtManifestProblem[] {
544
+ protected getConfigProblems(_extManifest: ExtManifest<ExtType>, _extName: string): ExtManifestProblem[] {
584
545
  void _extManifest;
585
546
  void _extName;
586
547
  return [];
@@ -604,13 +565,11 @@ export abstract class ExtensionConfig<ExtType extends ExtensionType> {
604
565
  if (extensionManifest.type === 'module' && extensionManifest.exports) {
605
566
  entryPointRelativePath = resolveEsmEntryPoint(extensionManifest.exports);
606
567
  }
607
- entryPointRelativePath =
608
- entryPointRelativePath ?? extensionManifest.main ?? DEFAULT_ENTRY_POINT;
568
+ entryPointRelativePath = entryPointRelativePath ?? extensionManifest.main ?? DEFAULT_ENTRY_POINT;
609
569
  } catch (e: any) {
610
- throw new ReferenceError(
611
- `Could not find the ${this.extensionType} installed at ${moduleRoot}: ${e.message}`,
612
- {cause: e},
613
- );
570
+ throw new ReferenceError(`Could not find the ${this.extensionType} installed at ${moduleRoot}: ${e.message}`, {
571
+ cause: e,
572
+ });
614
573
  }
615
574
  const entryPointFullPath = path.resolve(moduleRoot, entryPointRelativePath as string);
616
575
  if (!(await fs.exists(entryPointFullPath))) {
@@ -633,10 +592,7 @@ export abstract class ExtensionConfig<ExtType extends ExtensionType> {
633
592
  * @param extName - Manifest key
634
593
  * @param extManifest - Entry used for version and kind-specific labels
635
594
  */
636
- public abstract extensionDesc(
637
- extName: ExtName<ExtType>,
638
- extManifest: ExtManifest<ExtType>,
639
- ): string;
595
+ public abstract extensionDesc(extName: ExtName<ExtType>, extManifest: ExtManifest<ExtType>): string;
640
596
  }
641
597
 
642
598
  /**
@@ -1,12 +1,13 @@
1
- import {util, timing} from '@appium/support';
2
- import {asyncmap} from 'asyncbox';
1
+ import {timing, util} from '@appium/support';
3
2
  import type {DriverClass, ExtensionType, PluginClass} from '@appium/types';
4
3
  import type {ExtClass} from 'appium/types';
4
+ import {asyncmap} from 'asyncbox';
5
+
5
6
  import {USE_ALL_PLUGINS} from '../constants';
6
7
  import {log} from '../logger';
8
+ import {zip} from '../utils';
7
9
  import {DriverConfig} from './driver-config';
8
10
  import {Manifest} from './manifest';
9
- import {zip} from '../utils';
10
11
  import {PluginConfig} from './plugin-config';
11
12
 
12
13
  export type ExtensionConfigs = {
@@ -59,26 +60,18 @@ export async function getActivePlugins(
59
60
  if (pluginName in pluginConfig.installedExtensions) {
60
61
  filteredPluginNames.push(pluginName);
61
62
  } else if (pluginName === USE_ALL_PLUGINS) {
62
- throw new Error(
63
- `The reserved plugin name '${pluginName}' cannot be combined with other names.`,
64
- );
63
+ throw new Error(`The reserved plugin name '${pluginName}' cannot be combined with other names.`);
65
64
  } else {
66
65
  const suffix = util.isEmpty(pluginConfig.installedExtensions)
67
66
  ? `You don't have any plugins installed yet.`
68
- : `Only the following ${Object.keys(pluginConfig.installedExtensions).length === 1 ? `plugin is` : `plugins are`} ` +
69
- `available: ${Object.keys(pluginConfig.installedExtensions)}`;
70
- throw new Error(
71
- `Could not load the plugin '${pluginName}' because it is not installed. ${suffix}`,
72
- );
67
+ : `Only the following ${
68
+ Object.keys(pluginConfig.installedExtensions).length === 1 ? `plugin is` : `plugins are`
69
+ } ` + `available: ${Object.keys(pluginConfig.installedExtensions)}`;
70
+ throw new Error(`Could not load the plugin '${pluginName}' because it is not installed. ${suffix}`);
73
71
  }
74
72
  }
75
73
  }
76
- const pairs = await importExtensions(
77
- 'plugin',
78
- pluginConfig,
79
- filteredPluginNames,
80
- maxParallelImports,
81
- );
74
+ const pairs = await importExtensions('plugin', pluginConfig, filteredPluginNames, maxParallelImports);
82
75
  return new Map(pairs as Array<[PluginClass, string]>);
83
76
  }
84
77
 
@@ -102,20 +95,14 @@ export async function getActiveDrivers(
102
95
  } else {
103
96
  const suffix = util.isEmpty(driverConfig.installedExtensions)
104
97
  ? `You don't have any drivers installed yet.`
105
- : `Only the following ${Object.keys(driverConfig.installedExtensions).length === 1 ? `driver is` : `drivers are`} ` +
106
- `available: ${Object.keys(driverConfig.installedExtensions)}`;
107
- throw new Error(
108
- `Could not load the driver '${driverName}' because it is not installed. ${suffix}`,
109
- );
98
+ : `Only the following ${
99
+ Object.keys(driverConfig.installedExtensions).length === 1 ? `driver is` : `drivers are`
100
+ } ` + `available: ${Object.keys(driverConfig.installedExtensions)}`;
101
+ throw new Error(`Could not load the driver '${driverName}' because it is not installed. ${suffix}`);
110
102
  }
111
103
  }
112
104
  }
113
- const pairs = await importExtensions(
114
- 'driver',
115
- driverConfig,
116
- filteredDriverNames,
117
- maxParallelImports,
118
- );
105
+ const pairs = await importExtensions('driver', driverConfig, filteredDriverNames, maxParallelImports);
119
106
  return new Map(pairs as Array<[DriverClass, string]>);
120
107
  }
121
108
 
@@ -132,9 +119,7 @@ async function importExtensions(
132
119
  const timer = new timing.Timer().start();
133
120
  try {
134
121
  const extClass = await config.requireAsync(extName as never);
135
- log.debug(
136
- `${extClass.name} has been successfully loaded in ${timer.getDuration().asSeconds.toFixed(3)}s`,
137
- );
122
+ log.debug(`${extClass.name} has been successfully loaded in ${timer.getDuration().asSeconds.toFixed(3)}s`);
138
123
  return extClass as ExtClass<ExtensionType>;
139
124
  } catch (err: any) {
140
125
  log.error(
@@ -1,4 +1,5 @@
1
1
  import type {ManifestDataVersions} from 'appium/types';
2
+
2
3
  import {CURRENT_SCHEMA_REV, DRIVER_TYPE, PLUGIN_TYPE} from '../constants';
3
4
  import {log} from '../logger';
4
5
  import type {Manifest} from './manifest';
@@ -1,17 +1,13 @@
1
- import {env, fs, util} from '@appium/support';
2
1
  import path from 'node:path';
3
- import * as YAML from 'yaml';
2
+
3
+ import {env, fs, util} from '@appium/support';
4
4
  import type {DriverType, ExtensionType, PluginType} from '@appium/types';
5
- import type {
6
- ExtManifest,
7
- ExtPackageJson,
8
- ExtRecord,
9
- InternalMetadata,
10
- ManifestData,
11
- } from 'appium/types';
5
+ import type {ExtManifest, ExtPackageJson, ExtRecord, InternalMetadata, ManifestData} from 'appium/types';
6
+ import * as YAML from 'yaml';
7
+
12
8
  import {CURRENT_SCHEMA_REV, DRIVER_TYPE, PLUGIN_TYPE} from '../constants';
13
- import {INSTALL_TYPE_DEV, INSTALL_TYPE_NPM} from './extension-config';
14
9
  import {packageDidChange} from '../utils';
10
+ import {INSTALL_TYPE_DEV, INSTALL_TYPE_NPM} from './extension-config';
15
11
  import {migrate} from './manifest-migrations';
16
12
 
17
13
  const CONFIG_DATA_DRIVER_KEY = `${DRIVER_TYPE}s` as const;
@@ -120,9 +116,7 @@ export class Manifest {
120
116
  } else {
121
117
  throw new Error(
122
118
  `Appium had trouble loading the extension installation ` +
123
- `cache file (${manifestPathResolved}). It may be invalid YAML. Specific error: ${
124
- err.message
125
- }`,
119
+ `cache file (${manifestPathResolved}). It may be invalid YAML. Specific error: ${err.message}`,
126
120
  {cause: err},
127
121
  );
128
122
  }
@@ -180,9 +174,7 @@ export class Manifest {
180
174
  return true;
181
175
  } catch (err: any) {
182
176
  throw new Error(
183
- `Appium could not write to manifest at ${manifestPathResolved} using APPIUM_HOME ${
184
- this.#appiumHome
185
- }. Please ensure it is writable. Original error: ${err.message}`,
177
+ `Appium could not write to manifest at ${manifestPathResolved} using APPIUM_HOME ${this.#appiumHome}. Please ensure it is writable. Original error: ${err.message}`,
186
178
  {cause: err},
187
179
  );
188
180
  }
@@ -337,9 +329,7 @@ export class Manifest {
337
329
 
338
330
  if (path.relative(this.#appiumHome, resolved).startsWith('.')) {
339
331
  throw new Error(
340
- `Mismatch between location of APPIUM_HOME and manifest file. APPIUM_HOME: ${
341
- this.appiumHome
342
- }, manifest file: ${resolved}`,
332
+ `Mismatch between location of APPIUM_HOME and manifest file. APPIUM_HOME: ${this.appiumHome}, manifest file: ${resolved}`,
343
333
  );
344
334
  }
345
335
  }
@@ -1,6 +1,7 @@
1
1
  import {util} from '@appium/support';
2
2
  import type {PluginType} from '@appium/types';
3
3
  import type {ExtManifest, ExtName, ExtRecord} from 'appium/types';
4
+
4
5
  import {PLUGIN_TYPE} from '../constants';
5
6
  import {log} from '../logger';
6
7
  import {ExtensionConfig} from './extension-config';
@@ -32,10 +33,7 @@ export class PluginConfig extends ExtensionConfig<PluginType> {
32
33
  return await super._validate(this.manifest.getExtensionData(PLUGIN_TYPE));
33
34
  }
34
35
 
35
- public override extensionDesc(
36
- pluginName: ExtName<PluginType>,
37
- {version}: ExtManifest<PluginType>,
38
- ): string {
36
+ public override extensionDesc(pluginName: ExtName<PluginType>, {version}: ExtManifest<PluginType>): string {
39
37
  return `${String(pluginName)}@${version}`;
40
38
  }
41
39
 
@@ -44,8 +42,7 @@ export class PluginConfig extends ExtensionConfig<PluginType> {
44
42
 
45
43
  if (util.isEmpty(pluginNames)) {
46
44
  log.info(
47
- `No plugins have been installed. Use the "appium plugin" ` +
48
- 'command to install the one(s) you want to use.',
45
+ `No plugins have been installed. Use the "appium plugin" ` + 'command to install the one(s) you want to use.',
49
46
  );
50
47
  return;
51
48
  }
@@ -53,15 +50,11 @@ export class PluginConfig extends ExtensionConfig<PluginType> {
53
50
  log.info(`Available plugins:`);
54
51
  for (const [pluginName, pluginData] of Object.entries(this.installedExtensions)) {
55
52
  const activeTxt = activeNames.includes(pluginName as ExtName<PluginType>) ? ' (ACTIVE)' : '';
56
- log.info(
57
- ` - ${this.extensionDesc(pluginName as ExtName<PluginType>, pluginData)}${activeTxt}`,
58
- );
53
+ log.info(` - ${this.extensionDesc(pluginName as ExtName<PluginType>, pluginData)}${activeTxt}`);
59
54
  }
60
55
 
61
56
  if (util.isEmpty(activeNames)) {
62
- log.info(
63
- 'No plugins activated. Use the --use-plugins flag with names of plugins to activate',
64
- );
57
+ log.info('No plugins activated. Use the --use-plugins flag with names of plugins to activate');
65
58
  }
66
59
  }
67
60
  }