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