appium 3.2.2 → 3.3.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 (120) hide show
  1. package/build/lib/cli/args.d.ts +16 -12
  2. package/build/lib/cli/args.d.ts.map +1 -1
  3. package/build/lib/cli/args.js +15 -35
  4. package/build/lib/cli/args.js.map +1 -1
  5. package/build/lib/cli/driver-command.d.ts +51 -93
  6. package/build/lib/cli/driver-command.d.ts.map +1 -1
  7. package/build/lib/cli/driver-command.js +11 -66
  8. package/build/lib/cli/driver-command.js.map +1 -1
  9. package/build/lib/cli/extension-command.d.ts +211 -415
  10. package/build/lib/cli/extension-command.d.ts.map +1 -1
  11. package/build/lib/cli/extension-command.js +384 -653
  12. package/build/lib/cli/extension-command.js.map +1 -1
  13. package/build/lib/cli/extension.d.ts +11 -16
  14. package/build/lib/cli/extension.d.ts.map +1 -1
  15. package/build/lib/cli/extension.js +10 -28
  16. package/build/lib/cli/extension.js.map +1 -1
  17. package/build/lib/cli/parser.d.ts +40 -69
  18. package/build/lib/cli/parser.d.ts.map +1 -1
  19. package/build/lib/cli/parser.js +24 -59
  20. package/build/lib/cli/parser.js.map +1 -1
  21. package/build/lib/cli/plugin-command.d.ts +50 -90
  22. package/build/lib/cli/plugin-command.d.ts.map +1 -1
  23. package/build/lib/cli/plugin-command.js +11 -63
  24. package/build/lib/cli/plugin-command.js.map +1 -1
  25. package/build/lib/cli/setup-command.d.ts +21 -26
  26. package/build/lib/cli/setup-command.d.ts.map +1 -1
  27. package/build/lib/cli/setup-command.js +13 -55
  28. package/build/lib/cli/setup-command.js.map +1 -1
  29. package/build/lib/cli/utils.d.ts +27 -29
  30. package/build/lib/cli/utils.d.ts.map +1 -1
  31. package/build/lib/cli/utils.js +29 -31
  32. package/build/lib/cli/utils.js.map +1 -1
  33. package/build/lib/config-file.d.ts +24 -67
  34. package/build/lib/config-file.d.ts.map +1 -1
  35. package/build/lib/config-file.js +56 -115
  36. package/build/lib/config-file.js.map +1 -1
  37. package/build/lib/config.d.ts +42 -44
  38. package/build/lib/config.d.ts.map +1 -1
  39. package/build/lib/config.js +75 -107
  40. package/build/lib/config.js.map +1 -1
  41. package/build/lib/constants.d.ts +23 -23
  42. package/build/lib/constants.d.ts.map +1 -1
  43. package/build/lib/constants.js +10 -15
  44. package/build/lib/constants.js.map +1 -1
  45. package/build/lib/doctor/doctor.d.ts +40 -57
  46. package/build/lib/doctor/doctor.d.ts.map +1 -1
  47. package/build/lib/doctor/doctor.js +29 -60
  48. package/build/lib/doctor/doctor.js.map +1 -1
  49. package/build/lib/grid-register.d.ts +32 -7
  50. package/build/lib/grid-register.d.ts.map +1 -1
  51. package/build/lib/grid-register.js +84 -48
  52. package/build/lib/grid-register.js.map +1 -1
  53. package/build/lib/logsink.d.ts +13 -22
  54. package/build/lib/logsink.d.ts.map +1 -1
  55. package/build/lib/logsink.js +48 -103
  56. package/build/lib/logsink.js.map +1 -1
  57. package/build/lib/main.js +1 -1
  58. package/build/lib/main.js.map +1 -1
  59. package/build/lib/schema/arg-spec.d.ts +32 -107
  60. package/build/lib/schema/arg-spec.d.ts.map +1 -1
  61. package/build/lib/schema/arg-spec.js +11 -107
  62. package/build/lib/schema/arg-spec.js.map +1 -1
  63. package/build/lib/schema/cli-args.d.ts +3 -15
  64. package/build/lib/schema/cli-args.d.ts.map +1 -1
  65. package/build/lib/schema/cli-args.js +15 -105
  66. package/build/lib/schema/cli-args.js.map +1 -1
  67. package/build/lib/schema/cli-transformers.d.ts +15 -12
  68. package/build/lib/schema/cli-transformers.d.ts.map +1 -1
  69. package/build/lib/schema/cli-transformers.js +15 -45
  70. package/build/lib/schema/cli-transformers.js.map +1 -1
  71. package/build/lib/schema/index.d.ts +2 -2
  72. package/build/lib/schema/index.d.ts.map +1 -1
  73. package/build/lib/schema/index.js.map +1 -1
  74. package/build/lib/schema/keywords.d.ts +12 -20
  75. package/build/lib/schema/keywords.d.ts.map +1 -1
  76. package/build/lib/schema/keywords.js +6 -51
  77. package/build/lib/schema/keywords.js.map +1 -1
  78. package/build/lib/schema/schema.d.ts +106 -231
  79. package/build/lib/schema/schema.d.ts.map +1 -1
  80. package/build/lib/schema/schema.js +75 -345
  81. package/build/lib/schema/schema.js.map +1 -1
  82. package/build/lib/utils.d.ts +59 -238
  83. package/build/lib/utils.d.ts.map +1 -1
  84. package/build/lib/utils.js +55 -207
  85. package/build/lib/utils.js.map +1 -1
  86. package/lib/cli/{args.js → args.ts} +40 -51
  87. package/lib/cli/driver-command.ts +122 -0
  88. package/lib/cli/{extension-command.js → extension-command.ts} +610 -689
  89. package/lib/cli/extension.ts +65 -0
  90. package/lib/cli/{parser.js → parser.ts} +48 -71
  91. package/lib/cli/plugin-command.ts +117 -0
  92. package/lib/cli/{setup-command.js → setup-command.ts} +57 -72
  93. package/lib/cli/utils.ts +97 -0
  94. package/lib/config-file.ts +212 -0
  95. package/lib/{config.js → config.ts} +129 -141
  96. package/lib/{constants.js → constants.ts} +30 -41
  97. package/lib/doctor/{doctor.js → doctor.ts} +81 -91
  98. package/lib/grid-register.ts +250 -0
  99. package/lib/{logsink.js → logsink.ts} +91 -137
  100. package/lib/main.js +1 -1
  101. package/lib/schema/arg-spec.ts +131 -0
  102. package/lib/schema/cli-args.ts +171 -0
  103. package/lib/schema/cli-transformers.ts +83 -0
  104. package/lib/schema/keywords.ts +96 -0
  105. package/lib/schema/schema.ts +449 -0
  106. package/lib/utils.ts +404 -0
  107. package/package.json +16 -16
  108. package/lib/cli/driver-command.js +0 -174
  109. package/lib/cli/extension.js +0 -74
  110. package/lib/cli/plugin-command.js +0 -164
  111. package/lib/cli/utils.js +0 -91
  112. package/lib/config-file.js +0 -228
  113. package/lib/grid-register.js +0 -146
  114. package/lib/schema/arg-spec.js +0 -229
  115. package/lib/schema/cli-args.js +0 -254
  116. package/lib/schema/cli-transformers.js +0 -113
  117. package/lib/schema/keywords.js +0 -136
  118. package/lib/schema/schema.js +0 -725
  119. package/lib/utils.js +0 -512
  120. /package/lib/schema/{index.js → index.ts} +0 -0
@@ -1,445 +1,176 @@
1
- /**
2
- * This is needed to ensure proper module resolution for installed extensions,
3
- * especially ESM ones.
4
- *
5
- * @param {ExtensionConfig<ExtensionType>} driverConfig
6
- * @param {ExtensionConfig<ExtensionType>} pluginConfig
7
- * @param {import('@appium/types').AppiumLogger} logger
8
- */
9
- export function injectAppiumSymlinks(driverConfig: ExtensionConfig<ExtensionType>, pluginConfig: ExtensionConfig<ExtensionType>, logger: import("@appium/types").AppiumLogger): Promise<void>;
10
- export default ExtensionCliCommand;
11
- export { ExtensionCliCommand as ExtensionCommand };
1
+ import type { AppiumLogger, ExtensionType } from '@appium/types';
2
+ import type { ExtInstallReceipt as AppiumExtInstallReceipt, ExtManifest as AppiumExtManifest, ExtMetadata as AppiumExtMetadata, ExtPackageJson as AppiumExtPackageJson, ExtRecord as AppiumExtRecord, InstallType } from 'appium/types';
3
+ import type { ExtensionConfig as BaseExtensionConfig } from '../extension/extension-config';
12
4
  /**
13
5
  * Options for the {@linkcode ExtensionCliCommand} constructor
14
6
  */
15
- export type ExtensionCommandOptions<ExtType extends ExtensionType> = {
16
- /**
17
- * - the `DriverConfig` or `PluginConfig` instance used for this command
18
- */
7
+ export type ExtensionCommandOptions<ExtType extends ExtensionType = ExtensionType> = {
19
8
  config: ExtensionConfig<ExtType>;
20
- /**
21
- * - whether the output of this command should be JSON or text
22
- */
23
9
  json: boolean;
24
10
  };
11
+ export type ExtensionConfig<ExtType extends ExtensionType = ExtensionType> = BaseExtensionConfig<ExtType>;
12
+ export type ExtRecord<ExtType extends ExtensionType = ExtensionType> = AppiumExtRecord<ExtType>;
13
+ export type ExtMetadata<ExtType extends ExtensionType = ExtensionType> = AppiumExtMetadata<ExtType>;
14
+ export type ExtManifest<ExtType extends ExtensionType = ExtensionType> = AppiumExtManifest<ExtType>;
15
+ export type ExtPackageJson<ExtType extends ExtensionType = ExtensionType> = AppiumExtPackageJson<ExtType>;
16
+ export type ExtInstallReceipt<ExtType extends ExtensionType = ExtensionType> = AppiumExtInstallReceipt<ExtType>;
25
17
  /**
26
18
  * Extra stuff about extensions; used indirectly by {@linkcode ExtensionCliCommand.list}.
27
19
  */
28
20
  export type ExtensionListMetadata = {
29
- /**
30
- * - If `true`, the extension is installed
31
- */
32
21
  installed: boolean;
33
- /**
34
- * - If the extension is installed and the latest
35
- */
36
- upToDate: boolean;
37
- /**
38
- * - If the extension is installed, the version it can be updated to
39
- */
40
- updateVersion: string | null;
41
- /**
42
- * - Same as above, but a major version bump
43
- */
44
- unsafeUpdateVersion: string | null;
45
- /**
46
- * - Update check error message (if present)
47
- */
48
- updateError?: string | undefined;
49
- /**
50
- * - If Appium is run from an extension's working copy
51
- */
52
- devMode?: boolean | undefined;
53
- /**
54
- * - Repository URL for the extension (if available)
55
- */
56
- repositoryUrl?: string | undefined;
22
+ upToDate?: boolean;
23
+ updateVersion?: string | null;
24
+ unsafeUpdateVersion?: string | null;
25
+ updateError?: string;
26
+ devMode?: boolean;
27
+ repositoryUrl?: string;
57
28
  };
58
- export type ExtensionType = import("@appium/types").ExtensionType;
59
- export type DriverType = import("@appium/types").DriverType;
60
- export type PluginType = import("@appium/types").PluginType;
61
- export type ExtRecord<ExtType extends ExtensionType> = import("appium/types").ExtRecord<ExtType>;
62
- export type ExtensionConfig<ExtType extends ExtensionType> = import("../extension/extension-config").ExtensionConfig<ExtType>;
63
- export type ExtMetadata<ExtType extends ExtensionType> = import("appium/types").ExtMetadata<ExtType>;
64
- export type ExtManifest<ExtType extends ExtensionType> = import("appium/types").ExtManifest<ExtType>;
65
- export type ExtPackageJson<ExtType extends ExtensionType> = import("appium/types").ExtPackageJson<ExtType>;
66
- export type ExtInstallReceipt<ExtType extends ExtensionType> = import("appium/types").ExtInstallReceipt<ExtType>;
67
29
  /**
68
30
  * Possible return value for {@linkcode ExtensionCliCommand.list}
69
31
  */
70
- export type ExtensionListData<ExtType extends ExtensionType> = Partial<ExtManifest<ExtType>> & Partial<ExtensionListMetadata>;
71
- export type InstalledExtensionListData<ExtType extends ExtensionType> = ExtManifest<ExtType> & ExtensionListMetadata;
32
+ export type ExtensionListData<ExtType extends ExtensionType = ExtensionType> = Partial<ExtManifest<ExtType>> & Partial<ExtensionListMetadata>;
33
+ export type InstalledExtensionListData<ExtType extends ExtensionType = ExtensionType> = ExtManifest<ExtType> & ExtensionListMetadata;
72
34
  /**
73
35
  * Return value of {@linkcode ExtensionCliCommand.list}.
74
36
  */
75
- export type ExtensionList<ExtType extends ExtensionType> = Record<string, ExtensionListData<ExtType>>;
76
- /**
77
- * Options for {@linkcode ExtensionCliCommand._run}.
78
- */
79
- export type RunOptions = {
80
- /**
81
- * - name of the extension to run a script from
82
- */
83
- installSpec: string;
84
- /**
85
- * - name of the script to run. If not provided
86
- * then all available script names will be printed
87
- */
88
- scriptName?: string | undefined;
89
- /**
90
- * - arguments to pass to the script
91
- */
92
- extraArgs?: string[] | undefined;
93
- /**
94
- * - if true, will buffer the output of the script and return it
95
- */
96
- bufferOutput?: boolean | undefined;
97
- };
98
- /**
99
- * Options for {@linkcode ExtensionCliCommand.doctor}.
100
- */
101
- export type DoctorOptions = {
102
- /**
103
- * - name of the extension to run doctor checks for
104
- */
105
- installSpec: string;
106
- };
107
- /**
108
- * Return value of {@linkcode ExtensionCliCommand._run}
109
- */
110
- export type RunOutput = {
111
- /**
112
- * - script output if `bufferOutput` was `true` in {@linkcode RunOptions}
113
- */
114
- output?: string[] | undefined;
115
- };
116
- /**
117
- * Options for {@linkcode ExtensionCliCommand._update}.
118
- */
119
- export type ExtensionUpdateOpts = {
120
- /**
121
- * - the name of the extension to update
122
- */
123
- installSpec: string;
124
- /**
125
- * - if true, will perform unsafe updates past major revision boundaries
126
- */
127
- unsafe: boolean;
128
- };
129
- /**
130
- * Return value of {@linkcode ExtensionCliCommand._update}.
131
- */
132
- export type ExtensionUpdateResult = {
133
- /**
134
- * - map of ext names to error objects
135
- */
136
- errors: Record<string, Error>;
37
+ export type ExtensionList<ExtType extends ExtensionType = ExtensionType> = Record<string, ExtensionListData<ExtType>>;
38
+ declare abstract class ExtensionCliCommand<ExtType extends ExtensionType = ExtensionType> {
137
39
  /**
138
- * - map of ext names to {@linkcode UpdateReport}s
139
- */
140
- updates: Record<string, UpdateReport>;
141
- };
142
- /**
143
- * Part of result of {@linkcode ExtensionCliCommand._update}.
144
- */
145
- export type UpdateReport = {
146
- /**
147
- * - version the extension was updated from
148
- */
149
- from: string;
150
- /**
151
- * - version the extension was updated to
152
- */
153
- to: string;
154
- };
155
- /**
156
- * Options for {@linkcode ExtensionCliCommand._uninstall}.
157
- */
158
- export type UninstallOpts = {
159
- /**
160
- * - the name or spec of an extension to uninstall
161
- */
162
- installSpec: string;
163
- };
164
- /**
165
- * Used by {@linkcode ExtensionCliCommand.getPostInstallText}
166
- */
167
- export type ExtensionArgs = {
168
- /**
169
- * - the name of an extension
170
- */
171
- extName: string;
172
- /**
173
- * - the data for an installed extension
174
- */
175
- extData: object;
176
- };
177
- /**
178
- * Options for {@linkcode ExtensionCliCommand.installViaNpm}
179
- */
180
- export type InstallViaNpmArgs = {
181
- /**
182
- * - the name or spec of an extension to install
183
- */
184
- installSpec: string;
185
- /**
186
- * - the NPM package name of the extension
187
- */
188
- pkgName: string;
189
- /**
190
- * - type of install
191
- */
192
- installType: import("appium/types").InstallType;
193
- /**
194
- * - the specific version of the NPM package
195
- */
196
- pkgVer?: string | undefined;
197
- };
198
- /**
199
- * Object returned by {@linkcode ExtensionCliCommand.checkForExtensionUpdate}
200
- */
201
- export type PossibleUpdates = {
202
- /**
203
- * - current version
204
- */
205
- current: string;
206
- /**
207
- * - version we can safely update to if it exists, or null
208
- */
209
- safeUpdate: string | null;
210
- /**
211
- * - version we can unsafely update to if it exists, or null
212
- */
213
- unsafeUpdate: string | null;
214
- };
215
- /**
216
- * Options for {@linkcode ExtensionCliCommand._install}
217
- */
218
- export type InstallOpts = {
219
- /**
220
- * - the name or spec of an extension to install
40
+ * This is the `DriverConfig` or `PluginConfig`, depending on `ExtType`.
221
41
  */
222
- installSpec: string;
42
+ protected readonly config: ExtensionConfig<ExtType>;
223
43
  /**
224
- * - how to install this extension. One of the INSTALL_TYPES
44
+ * {@linkcode Record} of official plugins or drivers.
225
45
  */
226
- installType: InstallType;
46
+ protected knownExtensions: Record<string, string>;
227
47
  /**
228
- * - for git/github installs, the extension node package name
229
- */
230
- packageName?: string | undefined;
231
- };
232
- export type KnownExtensions<ExtType extends ExtensionType> = ExtType extends DriverType ? typeof import("../constants").KNOWN_DRIVERS : ExtType extends PluginType ? typeof import("../constants").KNOWN_PLUGINS : never;
233
- export type ListOptions = {
234
- /**
235
- * - whether should show only installed extensions
48
+ * If `true`, command output has been requested as JSON.
236
49
  */
237
- showInstalled: boolean;
50
+ protected readonly isJsonOutput: boolean;
51
+ protected readonly log: any;
238
52
  /**
239
- * - whether should show available updates
240
- */
241
- showUpdates: boolean;
242
- /**
243
- * - whether to show additional data from the extension
244
- */
245
- verbose?: boolean | undefined;
246
- };
247
- /**
248
- * Opts for {@linkcode ExtensionCliCommand.getInstallationReceipt}
249
- */
250
- export type GetInstallationReceiptOpts<ExtType extends ExtensionType> = {
251
- installPath: string;
252
- installSpec: string;
253
- pkg: ExtPackageJson<ExtType>;
254
- installType: InstallType;
255
- };
256
- export type InstallType = import("appium/types").InstallType;
257
- /**
258
- * @template {ExtensionType} ExtType
259
- */
260
- declare class ExtensionCliCommand<ExtType extends ExtensionType> {
261
- /**
262
- * Build an ExtensionCommand
263
- * @param {ExtensionCommandOptions<ExtType>} opts
53
+ * Creates an extension command instance.
54
+ *
55
+ * @param opts - constructor options containing extension config and JSON mode
264
56
  */
265
57
  constructor({ config, json }: ExtensionCommandOptions<ExtType>);
266
58
  /**
267
- * This is the `DriverConfig` or `PluginConfig`, depending on `ExtType`.
268
- * @type {ExtensionConfig<ExtType>}
59
+ * `driver` or `plugin`, depending on the `ExtensionConfig`.
269
60
  */
270
- config: ExtensionConfig<ExtType>;
61
+ get type(): ExtensionType;
271
62
  /**
272
- * {@linkcode Record} of official plugins or drivers.
273
- * @type {KnownExtensions<ExtType>}
63
+ * Executes an extension subcommand from parsed CLI args.
64
+ *
65
+ * @param args - parsed CLI argument object
66
+ * @returns result of the executed extension subcommand
274
67
  */
275
- knownExtensions: KnownExtensions<ExtType>;
68
+ execute(args: Record<string, any>): Promise<unknown>;
276
69
  /**
277
- * If `true`, command output has been requested as JSON.
278
- * @type {boolean}
70
+ * Lists available/installed extensions and optional update metadata.
71
+ *
72
+ * @param opts - list command options
73
+ * @returns map of extension names to list data
279
74
  */
280
- isJsonOutput: boolean;
281
- log: console.CliConsole;
75
+ list({ showInstalled, showUpdates, verbose }: ListOptions): Promise<ExtensionList>;
282
76
  /**
283
- * `driver` or `plugin`, depending on the `ExtensionConfig`.
77
+ * For any `package.json` fields which a particular type of extension requires, validate the
78
+ * presence and form of those fields on the `package.json` data, throwing an error if anything is
79
+ * amiss.
80
+ *
81
+ * @param extMetadata - the data in the "appium" field of `package.json` for an extension
82
+ * @param installSpec - Extension name/spec
284
83
  */
285
- get type(): ExtType;
84
+ protected abstract validateExtensionFields(extMetadata: ExtMetadata<ExtType>, installSpec: string): void;
286
85
  /**
287
86
  * Logs a message and returns an {@linkcode Error} to throw.
288
87
  *
289
88
  * For TS to understand that a function throws an exception, it must actually throw an exception--
290
89
  * in other words, _calling_ a function which is guaranteed to throw an exception is not enough--
291
- * nor is something like `@returns {never}` which does not imply a thrown exception.
90
+ * nor is something like a `never` return annotation, which does not imply a thrown exception.
292
91
  *
293
- * @param {string} message
294
- * @protected
295
92
  * @throws {Error}
296
93
  */
297
94
  protected _createFatalError(message: string): Error;
298
- /**
299
- * Take a CLI parse and run an extension command based on its type
300
- *
301
- * @param {object} args - a key/value object with CLI flags and values
302
- * @return {Promise<object>} the result of the specific command which is executed
303
- */
304
- execute(args: object): Promise<object>;
305
- /**
306
- * List extensions
307
- *
308
- * @template {ExtensionType} ExtType
309
- * @param {ListOptions} opts
310
- * @return {Promise<ExtensionList<ExtType>>} map of extension names to extension data
311
- */
312
- list<ExtType_1 extends ExtensionType>({ showInstalled, showUpdates, verbose }: ListOptions): Promise<ExtensionList<ExtType_1>>;
313
95
  /**
314
96
  * Build the initial list data structure from installed and known extensions
315
97
  *
316
- * @template {ExtensionType} ExtType
317
- * @param {boolean} showInstalled
318
- * @returns {ExtensionList<ExtType>}
319
- * @private
320
98
  */
321
- private _buildListData;
322
- /**
323
- * Check for available updates for installed extensions
324
- *
325
- * @template {ExtensionType} ExtType
326
- * @param {ExtensionList<ExtType>} listData
327
- * @param {boolean} showUpdates
328
- * @param {string} lsMsg
329
- * @returns {Promise<void>}
330
- * @private
331
- */
332
- private _checkForUpdates;
333
- /**
334
- * Add repository URLs to list data for all extensions
335
- *
336
- * @template {ExtensionType} ExtType
337
- * @param {ExtensionList<ExtType>} listData
338
- * @returns {Promise<void>}
339
- * @private
340
- */
341
- private _addRepositoryUrlsToListData;
99
+ protected _install({ installSpec, installType, packageName }: InstallOpts): Promise<Record<string, any>>;
342
100
  /**
343
- * Display normal formatted output
101
+ * Get the text which should be displayed to the user after an extension has been installed. This
102
+ * is designed to be overridden by drivers/plugins with their own particular text.
344
103
  *
345
- * @template {ExtensionType} ExtType
346
- * @param {ExtensionList<ExtType>} listData
347
- * @param {boolean} showUpdates
348
- * @returns {Promise<ExtensionList<ExtType>>}
349
- * @private
350
104
  */
351
- private _displayNormalListOutput;
105
+ protected abstract getPostInstallText(args: ExtensionArgs<ExtType>): PostInstallText;
352
106
  /**
353
- * Format a single extension line for display
107
+ * Uninstall an extension.
354
108
  *
355
- * @template {ExtensionType} ExtType
356
- * @param {string} name
357
- * @param {ExtensionListData<ExtType>} data
358
- * @param {boolean} showUpdates
359
- * @returns {Promise<string>}
360
- * @private
361
- */
362
- private _formatExtensionLine;
363
- /**
364
- * Format installation status text
109
+ * First tries to do this via `npm uninstall`, but if that fails, just `rm -rf`'s the extension dir.
365
110
  *
366
- * @template {ExtensionType} ExtType
367
- * @param {InstalledExtensionListData<ExtType>} data
368
- * @returns {string}
369
- * @private
370
- */
371
- private _formatInstallText;
372
- /**
373
- * Format update information text
111
+ * Will only remove the extension from the manifest if it has been successfully removed.
374
112
  *
375
- * @template {ExtensionType} ExtType
376
- * @param {InstalledExtensionListData<ExtType>} data
377
- * @returns {string}
378
- * @private
113
+ * @return map of all installed extension names to extension data (without the extension just uninstalled)
379
114
  */
380
- private _formatUpdateText;
115
+ protected _uninstall({ installSpec }: UninstallOpts): Promise<Record<string, any>>;
381
116
  /**
382
- * Get repository URL from package data
117
+ * Attempt to update one or more drivers using NPM
383
118
  *
384
- * @template {ExtensionType} ExtType
385
- * @param {ExtensionListData<ExtType>} data
386
- * @returns {Promise<string|null>}
387
- * @private
388
119
  */
389
- private _getRepositoryUrl;
120
+ protected _update({ installSpec, unsafe }: ExtensionUpdateOpts): Promise<ExtensionUpdateResult>;
390
121
  /**
391
- * Get repository URL from installed extension's package.json
122
+ * Given an extension name, figure out what its highest possible version upgrade is, and also the
123
+ * highest possible safe upgrade.
392
124
  *
393
- * @template {ExtensionType} ExtType
394
- * @param {InstalledExtensionListData<ExtType>} data
395
- * @returns {Promise<string|null>}
396
- * @private
125
+ * @param ext - name of extension
397
126
  */
398
- private _getRepositoryUrlFromInstalled;
127
+ protected checkForExtensionUpdate(ext: string): Promise<PossibleUpdates>;
399
128
  /**
400
- * Get repository URL from npm for a package name
129
+ * Runs doctor checks for the given extension.
401
130
  *
402
- * @param {string} pkgName
403
- * @returns {Promise<string|null>}
404
- * @private
131
+ * @returns The amount of Doctor checks that were
132
+ * successfully loaded and executed for the given extension
133
+ * @throws {Error} If any of the mandatory Doctor checks fails.
405
134
  */
406
- private _getRepositoryUrlFromNpm;
135
+ protected _doctor({ installSpec }: DoctorOptions): Promise<number>;
407
136
  /**
408
- * Checks whether the given extension is compatible with the currently installed server
137
+ * Runs a script cached inside the `scripts` field under `appium`
138
+ * inside of the extension's `package.json` file. Will throw
139
+ * an error if the driver/plugin does not contain a `scripts` field
140
+ * underneath the `appium` field in its `package.json`, if the
141
+ * `scripts` field is not a plain object, or if the `scriptName` is
142
+ * not found within `scripts` object.
409
143
  *
410
- * @param {InstallViaNpmArgs} installViaNpmOpts
411
- * @returns {Promise<void>}
412
144
  */
413
- _checkInstallCompatibility({ installSpec, pkgName, pkgVer, installType }: InstallViaNpmArgs): Promise<void>;
145
+ protected _run({ installSpec, scriptName, extraArgs, bufferOutput, }: RunOptions): Promise<RunOutput>;
146
+ private _buildListData;
414
147
  /**
415
- * Install an extension
148
+ * Install an extension via NPM
416
149
  *
417
- * @param {InstallOpts} opts
418
- * @return {Promise<ExtRecord<ExtType>>} map of all installed extension names to extension data
419
150
  */
420
- _install({ installSpec, installType, packageName }: InstallOpts): Promise<ExtRecord<ExtType>>;
151
+ private installViaNpm;
421
152
  /**
422
- * Install an extension via NPM
153
+ * Actually update an extension installed by NPM, using the NPM cli. And update the installation
154
+ * manifest.
423
155
  *
424
- * @param {InstallViaNpmArgs} args
425
- * @returns {Promise<ExtInstallReceipt<ExtType>>}
156
+ * @param installSpec - name of extension to update
157
+ * @param version - version string identifier to update extension to
426
158
  */
427
- installViaNpm({ installSpec, pkgName, pkgVer, installType }: InstallViaNpmArgs): Promise<ExtInstallReceipt<ExtType>>;
159
+ private updateExtension;
428
160
  /**
429
- * Get the text which should be displayed to the user after an extension has been installed. This
430
- * is designed to be overridden by drivers/plugins with their own particular text.
161
+ * Just wraps {@linkcode child_process.spawn} with some default options
431
162
  *
432
- * @param {ExtensionArgs} args
433
- * @returns {string}
163
+ * @param cwd - CWD
164
+ * @param script - Path to script
165
+ * @param args - Extra args for script
166
+ * @param opts - Options
434
167
  */
435
- getPostInstallText(args: ExtensionArgs): string;
168
+ private _runUnbuffered;
436
169
  /**
437
170
  * Once a package is installed on-disk, this gathers some necessary metadata for validation.
438
171
  *
439
- * @param {GetInstallationReceiptOpts<ExtType>} opts
440
- * @returns {ExtInstallReceipt<ExtType>}
441
172
  */
442
- getInstallationReceipt({ pkg, installPath, installType, installSpec }: GetInstallationReceiptOpts<ExtType>): ExtInstallReceipt<ExtType>;
173
+ private getInstallationReceipt;
443
174
  /**
444
175
  * Validates the _required_ root fields of an extension's `package.json` file.
445
176
  *
@@ -447,87 +178,152 @@ declare class ExtensionCliCommand<ExtType extends ExtensionType> {
447
178
  * - `name`
448
179
  * - `version`
449
180
  * - `appium`
450
- * @param {import('type-fest').PackageJson} pkg - `package.json` of extension
451
- * @param {string} installSpec - Extension name/spec
181
+ * @param pkg - `package.json` of extension
182
+ * @param installSpec - Extension name/spec
452
183
  * @throws {ReferenceError} If `package.json` has a missing or invalid field
453
- * @returns {pkg is ExtPackageJson<ExtType>}
454
184
  */
455
- validatePackageJson(pkg: import("type-fest").PackageJson, installSpec: string): pkg is ExtPackageJson<ExtType>;
185
+ private validatePackageJson;
456
186
  /**
457
- * For any `package.json` fields which a particular type of extension requires, validate the
458
- * presence and form of those fields on the `package.json` data, throwing an error if anything is
459
- * amiss.
187
+ * Check for available updates for installed extensions
460
188
  *
461
- * @param {ExtMetadata<ExtType>} extMetadata - the data in the "appium" field of `package.json` for an extension
462
- * @param {string} installSpec - Extension name/spec
463
189
  */
464
- validateExtensionFields(extMetadata: ExtMetadata<ExtType>, installSpec: string): void;
190
+ private _checkForUpdates;
465
191
  /**
466
- * Uninstall an extension.
192
+ * Add repository URLs to list data for all extensions
467
193
  *
468
- * First tries to do this via `npm uninstall`, but if that fails, just `rm -rf`'s the extension dir.
194
+ */
195
+ private _addRepositoryUrlsToListData;
196
+ /**
197
+ * Display normal formatted output
469
198
  *
470
- * Will only remove the extension from the manifest if it has been successfully removed.
199
+ */
200
+ private _displayNormalListOutput;
201
+ /**
202
+ * Format a single extension line for display
471
203
  *
472
- * @param {UninstallOpts} opts
473
- * @return {Promise<ExtRecord<ExtType>>} map of all installed extension names to extension data (without the extension just uninstalled)
474
204
  */
475
- _uninstall({ installSpec }: UninstallOpts): Promise<ExtRecord<ExtType>>;
205
+ private _formatExtensionLine;
476
206
  /**
477
- * Attempt to update one or more drivers using NPM
207
+ * Format installation status text
478
208
  *
479
- * @param {ExtensionUpdateOpts} updateSpec
480
- * @return {Promise<ExtensionUpdateResult>}
481
209
  */
482
- _update({ installSpec, unsafe }: ExtensionUpdateOpts): Promise<ExtensionUpdateResult>;
210
+ private _formatInstallText;
483
211
  /**
484
- * Given an extension name, figure out what its highest possible version upgrade is, and also the
485
- * highest possible safe upgrade.
212
+ * Format update information text
486
213
  *
487
- * @param {string} ext - name of extension
488
- * @return {Promise<PossibleUpdates>}
489
214
  */
490
- checkForExtensionUpdate(ext: string): Promise<PossibleUpdates>;
215
+ private _formatUpdateText;
491
216
  /**
492
- * Actually update an extension installed by NPM, using the NPM cli. And update the installation
493
- * manifest.
217
+ * Get repository URL from package data
494
218
  *
495
- * @param {string} installSpec - name of extension to update
496
- * @param {string} version - version string identifier to update extension to
497
- * @returns {Promise<void>}
498
219
  */
499
- updateExtension(installSpec: string, version: string): Promise<void>;
220
+ private _getRepositoryUrl;
500
221
  /**
501
- * Just wraps {@linkcode child_process.spawn} with some default options
222
+ * Get repository URL from installed extension's package.json
502
223
  *
503
- * @param {string} cwd - CWD
504
- * @param {string} script - Path to script
505
- * @param {string[]} args - Extra args for script
506
- * @param {import('child_process').SpawnOptions} opts - Options
507
- * @returns {import('node:child_process').ChildProcess}
508
224
  */
509
- _runUnbuffered(cwd: string, script: string, args?: string[], opts?: import("child_process").SpawnOptions): import("node:child_process").ChildProcess;
225
+ private _getRepositoryUrlFromInstalled;
510
226
  /**
511
- * Runs doctor checks for the given extension.
227
+ * Get repository URL from npm for a package name
512
228
  *
513
- * @param {DoctorOptions} opts
514
- * @returns {Promise<number>} The amount of Doctor checks that were
515
- * successfully loaded and executed for the given extension
516
- * @throws {Error} If any of the mandatory Doctor checks fails.
517
229
  */
518
- _doctor({ installSpec }: DoctorOptions): Promise<number>;
230
+ private _getRepositoryUrlFromNpm;
519
231
  /**
520
- * Runs a script cached inside the `scripts` field under `appium`
521
- * inside of the extension's `package.json` file. Will throw
522
- * an error if the driver/plugin does not contain a `scripts` field
523
- * underneath the `appium` field in its `package.json`, if the
524
- * `scripts` field is not a plain object, or if the `scriptName` is
525
- * not found within `scripts` object.
232
+ * Checks whether the given extension is compatible with the currently installed server
526
233
  *
527
- * @param {RunOptions} opts
528
- * @return {Promise<RunOutput>}
529
234
  */
530
- _run({ installSpec, scriptName, extraArgs, bufferOutput }: RunOptions): Promise<RunOutput>;
235
+ private _checkInstallCompatibility;
531
236
  }
532
- import { console } from '@appium/support';
237
+ /**
238
+ * This is needed to ensure proper module resolution for installed extensions,
239
+ * especially ESM ones.
240
+ *
241
+ * @param driverConfig - active driver extension config
242
+ * @param pluginConfig - active plugin extension config
243
+ * @param logger - logger instance used for non-fatal symlink errors
244
+ * @returns resolves when symlink injection has completed for all extensions
245
+ */
246
+ export declare function injectAppiumSymlinks(driverConfig: ExtensionConfig<any>, pluginConfig: ExtensionConfig<any>, logger: AppiumLogger): Promise<void>;
247
+ /**
248
+ * Options for {@linkcode ExtensionCliCommand._run}.
249
+ */
250
+ type RunOptions = {
251
+ installSpec: string;
252
+ scriptName?: string;
253
+ extraArgs?: string[];
254
+ bufferOutput?: boolean;
255
+ };
256
+ /**
257
+ * Options for {@linkcode ExtensionCliCommand.doctor}.
258
+ */
259
+ type DoctorOptions = {
260
+ installSpec: string;
261
+ };
262
+ /**
263
+ * Return value of {@linkcode ExtensionCliCommand._run}
264
+ */
265
+ export type RunOutput = {
266
+ output?: string[];
267
+ };
268
+ /**
269
+ * Return type of {@linkcode ExtensionCliCommand.getPostInstallText}.
270
+ */
271
+ export type PostInstallText = string;
272
+ /**
273
+ * Options for {@linkcode ExtensionCliCommand._update}.
274
+ */
275
+ type ExtensionUpdateOpts = {
276
+ installSpec: string;
277
+ unsafe: boolean;
278
+ };
279
+ /**
280
+ * Part of result of {@linkcode ExtensionCliCommand._update}.
281
+ */
282
+ type UpdateReport = {
283
+ from: string;
284
+ to: string | null;
285
+ };
286
+ /**
287
+ * Return value of {@linkcode ExtensionCliCommand._update}.
288
+ */
289
+ export type ExtensionUpdateResult = {
290
+ errors: Record<string, Error>;
291
+ updates: Record<string, UpdateReport>;
292
+ };
293
+ /**
294
+ * Options for {@linkcode ExtensionCliCommand._uninstall}.
295
+ */
296
+ type UninstallOpts = {
297
+ installSpec: string;
298
+ };
299
+ /**
300
+ * Used by {@linkcode ExtensionCliCommand.getPostInstallText}
301
+ */
302
+ export type ExtensionArgs<ExtType extends ExtensionType = ExtensionType> = {
303
+ extName: string;
304
+ extData: ExtInstallReceipt<ExtType>;
305
+ };
306
+ /**
307
+ * Object returned by {@linkcode ExtensionCliCommand.checkForExtensionUpdate}
308
+ */
309
+ type PossibleUpdates = {
310
+ current: string;
311
+ safeUpdate: string | null;
312
+ unsafeUpdate: string | null;
313
+ };
314
+ /**
315
+ * Options for {@linkcode ExtensionCliCommand._install}
316
+ */
317
+ type InstallOpts = {
318
+ installSpec: string;
319
+ installType: InstallType;
320
+ packageName?: string;
321
+ };
322
+ type ListOptions = {
323
+ showInstalled: boolean;
324
+ showUpdates: boolean;
325
+ verbose?: boolean;
326
+ };
327
+ export default ExtensionCliCommand;
328
+ export { ExtensionCliCommand as ExtensionCommand };
533
329
  //# sourceMappingURL=extension-command.d.ts.map