appium 2.0.0-beta.7 → 2.0.0-beta.70

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 (206) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +149 -58
  3. package/build/lib/appium.d.ts +229 -0
  4. package/build/lib/appium.d.ts.map +1 -0
  5. package/build/lib/appium.js +678 -439
  6. package/build/lib/appium.js.map +1 -0
  7. package/build/lib/cli/args.d.ts +17 -0
  8. package/build/lib/cli/args.d.ts.map +1 -0
  9. package/build/lib/cli/args.js +263 -300
  10. package/build/lib/cli/args.js.map +1 -0
  11. package/build/lib/cli/driver-command.d.ts +102 -0
  12. package/build/lib/cli/driver-command.d.ts.map +1 -0
  13. package/build/lib/cli/driver-command.js +131 -81
  14. package/build/lib/cli/driver-command.js.map +1 -0
  15. package/build/lib/cli/extension-command.d.ts +402 -0
  16. package/build/lib/cli/extension-command.d.ts.map +1 -0
  17. package/build/lib/cli/extension-command.js +799 -383
  18. package/build/lib/cli/extension-command.js.map +1 -0
  19. package/build/lib/cli/extension.d.ts +23 -0
  20. package/build/lib/cli/extension.d.ts.map +1 -0
  21. package/build/lib/cli/extension.js +71 -60
  22. package/build/lib/cli/extension.js.map +1 -0
  23. package/build/lib/cli/parser.d.ts +84 -0
  24. package/build/lib/cli/parser.d.ts.map +1 -0
  25. package/build/lib/cli/parser.js +252 -148
  26. package/build/lib/cli/parser.js.map +1 -0
  27. package/build/lib/cli/plugin-command.d.ts +99 -0
  28. package/build/lib/cli/plugin-command.d.ts.map +1 -0
  29. package/build/lib/cli/plugin-command.js +125 -81
  30. package/build/lib/cli/plugin-command.js.map +1 -0
  31. package/build/lib/cli/utils.d.ts +29 -0
  32. package/build/lib/cli/utils.d.ts.map +1 -0
  33. package/build/lib/cli/utils.js +72 -51
  34. package/build/lib/cli/utils.js.map +1 -0
  35. package/build/lib/config-file.d.ts +100 -0
  36. package/build/lib/config-file.d.ts.map +1 -0
  37. package/build/lib/config-file.js +207 -0
  38. package/build/lib/config-file.js.map +1 -0
  39. package/build/lib/config.d.ts +49 -0
  40. package/build/lib/config.d.ts.map +1 -0
  41. package/build/lib/config.js +262 -223
  42. package/build/lib/config.js.map +1 -0
  43. package/build/lib/constants.d.ts +56 -0
  44. package/build/lib/constants.d.ts.map +1 -0
  45. package/build/lib/constants.js +73 -0
  46. package/build/lib/constants.js.map +1 -0
  47. package/build/lib/extension/driver-config.d.ts +82 -0
  48. package/build/lib/extension/driver-config.d.ts.map +1 -0
  49. package/build/lib/extension/driver-config.js +210 -0
  50. package/build/lib/extension/driver-config.js.map +1 -0
  51. package/build/lib/extension/extension-config.d.ts +270 -0
  52. package/build/lib/extension/extension-config.d.ts.map +1 -0
  53. package/build/lib/extension/extension-config.js +601 -0
  54. package/build/lib/extension/extension-config.js.map +1 -0
  55. package/build/lib/extension/index.d.ts +48 -0
  56. package/build/lib/extension/index.d.ts.map +1 -0
  57. package/build/lib/extension/index.js +105 -0
  58. package/build/lib/extension/index.js.map +1 -0
  59. package/build/lib/extension/manifest-migrations.d.ts +27 -0
  60. package/build/lib/extension/manifest-migrations.d.ts.map +1 -0
  61. package/build/lib/extension/manifest-migrations.js +134 -0
  62. package/build/lib/extension/manifest-migrations.js.map +1 -0
  63. package/build/lib/extension/manifest.d.ts +145 -0
  64. package/build/lib/extension/manifest.d.ts.map +1 -0
  65. package/build/lib/extension/manifest.js +528 -0
  66. package/build/lib/extension/manifest.js.map +1 -0
  67. package/build/lib/extension/package-changed.d.ts +11 -0
  68. package/build/lib/extension/package-changed.d.ts.map +1 -0
  69. package/build/lib/extension/package-changed.js +62 -0
  70. package/build/lib/extension/package-changed.js.map +1 -0
  71. package/build/lib/extension/plugin-config.d.ts +56 -0
  72. package/build/lib/extension/plugin-config.d.ts.map +1 -0
  73. package/build/lib/extension/plugin-config.js +102 -0
  74. package/build/lib/extension/plugin-config.js.map +1 -0
  75. package/build/lib/grid-register.d.ts +10 -0
  76. package/build/lib/grid-register.d.ts.map +1 -0
  77. package/build/lib/grid-register.js +122 -144
  78. package/build/lib/grid-register.js.map +1 -0
  79. package/build/lib/logger.d.ts +3 -0
  80. package/build/lib/logger.d.ts.map +1 -0
  81. package/build/lib/logger.js +5 -17
  82. package/build/lib/logger.js.map +1 -0
  83. package/build/lib/logsink.d.ts +4 -0
  84. package/build/lib/logsink.d.ts.map +1 -0
  85. package/build/lib/logsink.js +189 -184
  86. package/build/lib/logsink.js.map +1 -0
  87. package/build/lib/main.d.ts +62 -0
  88. package/build/lib/main.d.ts.map +1 -0
  89. package/build/lib/main.js +388 -234
  90. package/build/lib/main.js.map +1 -0
  91. package/build/lib/schema/arg-spec.d.ts +143 -0
  92. package/build/lib/schema/arg-spec.d.ts.map +1 -0
  93. package/build/lib/schema/arg-spec.js +164 -0
  94. package/build/lib/schema/arg-spec.js.map +1 -0
  95. package/build/lib/schema/cli-args.d.ts +19 -0
  96. package/build/lib/schema/cli-args.d.ts.map +1 -0
  97. package/build/lib/schema/cli-args.js +220 -0
  98. package/build/lib/schema/cli-args.js.map +1 -0
  99. package/build/lib/schema/cli-transformers.d.ts +5 -0
  100. package/build/lib/schema/cli-transformers.d.ts.map +1 -0
  101. package/build/lib/schema/cli-transformers.js +124 -0
  102. package/build/lib/schema/cli-transformers.js.map +1 -0
  103. package/build/lib/schema/index.d.ts +3 -0
  104. package/build/lib/schema/index.d.ts.map +1 -0
  105. package/build/lib/schema/index.js +19 -0
  106. package/build/lib/schema/index.js.map +1 -0
  107. package/build/lib/schema/keywords.d.ts +24 -0
  108. package/build/lib/schema/keywords.d.ts.map +1 -0
  109. package/build/lib/schema/keywords.js +128 -0
  110. package/build/lib/schema/keywords.js.map +1 -0
  111. package/build/lib/schema/schema.d.ts +260 -0
  112. package/build/lib/schema/schema.d.ts.map +1 -0
  113. package/build/lib/schema/schema.js +640 -0
  114. package/build/lib/schema/schema.js.map +1 -0
  115. package/build/lib/utils.d.ts +266 -0
  116. package/build/lib/utils.d.ts.map +1 -0
  117. package/build/lib/utils.js +349 -273
  118. package/build/lib/utils.js.map +1 -0
  119. package/build/types/cli.d.ts +134 -0
  120. package/build/types/cli.d.ts.map +1 -0
  121. package/build/types/cli.js +3 -0
  122. package/build/types/cli.js.map +1 -0
  123. package/build/types/index.d.ts +15 -0
  124. package/build/types/index.d.ts.map +1 -0
  125. package/build/types/index.js +19 -0
  126. package/build/types/index.js.map +1 -0
  127. package/build/types/manifest/base.d.ts +135 -0
  128. package/build/types/manifest/base.d.ts.map +1 -0
  129. package/build/types/manifest/base.js +3 -0
  130. package/build/types/manifest/base.js.map +1 -0
  131. package/build/types/manifest/index.d.ts +21 -0
  132. package/build/types/manifest/index.d.ts.map +1 -0
  133. package/build/types/manifest/index.js +42 -0
  134. package/build/types/manifest/index.js.map +1 -0
  135. package/build/types/manifest/v3.d.ts +139 -0
  136. package/build/types/manifest/v3.d.ts.map +1 -0
  137. package/build/types/manifest/v3.js +3 -0
  138. package/build/types/manifest/v3.js.map +1 -0
  139. package/build/types/manifest/v4.d.ts +139 -0
  140. package/build/types/manifest/v4.d.ts.map +1 -0
  141. package/build/types/manifest/v4.js +3 -0
  142. package/build/types/manifest/v4.js.map +1 -0
  143. package/driver.d.ts +1 -0
  144. package/driver.js +14 -0
  145. package/index.js +11 -0
  146. package/lib/appium.js +558 -186
  147. package/lib/cli/args.js +275 -407
  148. package/lib/cli/driver-command.js +132 -24
  149. package/lib/cli/extension-command.js +751 -272
  150. package/lib/cli/extension.js +47 -20
  151. package/lib/cli/parser.js +267 -95
  152. package/lib/cli/plugin-command.js +122 -22
  153. package/lib/cli/utils.js +24 -10
  154. package/lib/config-file.js +220 -0
  155. package/lib/config.js +243 -132
  156. package/lib/constants.js +79 -0
  157. package/lib/extension/driver-config.js +247 -0
  158. package/lib/extension/extension-config.js +709 -0
  159. package/lib/extension/index.js +116 -0
  160. package/lib/extension/manifest-migrations.js +136 -0
  161. package/lib/extension/manifest.js +580 -0
  162. package/lib/extension/package-changed.js +64 -0
  163. package/lib/extension/plugin-config.js +112 -0
  164. package/lib/grid-register.js +49 -35
  165. package/lib/logger.js +1 -2
  166. package/lib/logsink.js +59 -36
  167. package/lib/main.js +369 -104
  168. package/lib/schema/arg-spec.js +229 -0
  169. package/lib/schema/cli-args.js +241 -0
  170. package/lib/schema/cli-transformers.js +119 -0
  171. package/lib/schema/index.js +2 -0
  172. package/lib/schema/keywords.js +136 -0
  173. package/lib/schema/schema.js +725 -0
  174. package/lib/utils.js +289 -167
  175. package/package.json +84 -83
  176. package/plugin.d.ts +1 -0
  177. package/plugin.js +13 -0
  178. package/scripts/autoinstall-extensions.js +243 -0
  179. package/support.d.ts +1 -0
  180. package/support.js +13 -0
  181. package/tsconfig.json +25 -0
  182. package/types/cli.ts +193 -0
  183. package/types/index.ts +20 -0
  184. package/types/manifest/README.md +30 -0
  185. package/types/manifest/base.ts +158 -0
  186. package/types/manifest/index.ts +28 -0
  187. package/types/manifest/v3.ts +161 -0
  188. package/types/manifest/v4.ts +161 -0
  189. package/CHANGELOG.md +0 -3594
  190. package/bin/ios-webkit-debug-proxy-launcher.js +0 -71
  191. package/build/lib/cli/argparse-actions.js +0 -104
  192. package/build/lib/cli/npm.js +0 -200
  193. package/build/lib/cli/parser-helpers.js +0 -93
  194. package/build/lib/driver-config.js +0 -77
  195. package/build/lib/drivers.js +0 -99
  196. package/build/lib/extension-config.js +0 -253
  197. package/build/lib/plugin-config.js +0 -59
  198. package/build/lib/plugins.js +0 -14
  199. package/lib/cli/argparse-actions.js +0 -77
  200. package/lib/cli/npm.js +0 -175
  201. package/lib/cli/parser-helpers.js +0 -91
  202. package/lib/driver-config.js +0 -46
  203. package/lib/drivers.js +0 -84
  204. package/lib/extension-config.js +0 -209
  205. package/lib/plugin-config.js +0 -34
  206. package/lib/plugins.js +0 -10
@@ -0,0 +1,247 @@
1
+ import _ from 'lodash';
2
+ import {DRIVER_TYPE} from '../constants';
3
+ import log from '../logger';
4
+ import {ExtensionConfig} from './extension-config';
5
+
6
+ /**
7
+ * @extends {ExtensionConfig<DriverType>}
8
+ */
9
+ export class DriverConfig extends ExtensionConfig {
10
+ /**
11
+ * A set of unique automation names used by drivers.
12
+ * @type {Set<string>}
13
+ */
14
+ knownAutomationNames;
15
+
16
+ /**
17
+ * A mapping of {@link Manifest} instances to {@link DriverConfig} instances.
18
+ *
19
+ * `Manifest` and `ExtensionConfig` have a one-to-many relationship; each `Manifest` should be associated with a `DriverConfig` and a `PluginConfig`; no more, no less.
20
+ *
21
+ * This variable tracks the `Manifest`-to-`DriverConfig` portion.
22
+ *
23
+ * @type {WeakMap<Manifest,DriverConfig>}
24
+ * @private
25
+ */
26
+ static _instances = new WeakMap();
27
+
28
+ /**
29
+ * Call {@link DriverConfig.create} instead.
30
+ * @private
31
+ * @param {import('./manifest').Manifest} manifest - Manifest instance
32
+ */
33
+ constructor(manifest) {
34
+ super(DRIVER_TYPE, manifest);
35
+
36
+ this.knownAutomationNames = new Set();
37
+ }
38
+
39
+ /**
40
+ * Creates a new {@link DriverConfig} instance for a {@link Manifest} instance.
41
+ *
42
+ * @param {Manifest} manifest
43
+ * @throws If `manifest` already associated with a `DriverConfig`
44
+ * @returns {DriverConfig}
45
+ */
46
+ static create(manifest) {
47
+ const instance = new DriverConfig(manifest);
48
+ if (DriverConfig.getInstance(manifest)) {
49
+ throw new Error(
50
+ `Manifest with APPIUM_HOME ${manifest.appiumHome} already has a DriverConfig; use DriverConfig.getInstance() to retrieve it.`
51
+ );
52
+ }
53
+ DriverConfig._instances.set(manifest, instance);
54
+ return instance;
55
+ }
56
+
57
+ /**
58
+ * Returns a DriverConfig associated with a Manifest
59
+ * @param {Manifest} manifest
60
+ * @returns {DriverConfig|undefined}
61
+ */
62
+ static getInstance(manifest) {
63
+ return DriverConfig._instances.get(manifest);
64
+ }
65
+
66
+ /**
67
+ * Checks extensions for problems
68
+ */
69
+ async validate() {
70
+ this.knownAutomationNames.clear();
71
+ return await super._validate(this.manifest.getExtensionData(DRIVER_TYPE));
72
+ }
73
+
74
+ /**
75
+ * @param {ExtManifest<DriverType>} extData
76
+ * @returns {import('./extension-config').ExtManifestProblem[]}
77
+ */
78
+ getConfigProblems(extData) {
79
+ const problems = [];
80
+ const {platformNames, automationName} = extData;
81
+
82
+ if (!_.isArray(platformNames)) {
83
+ problems.push({
84
+ err: 'Missing or incorrect supported platformNames list.',
85
+ val: platformNames,
86
+ });
87
+ } else {
88
+ if (_.isEmpty(platformNames)) {
89
+ problems.push({
90
+ err: 'Empty platformNames list.',
91
+ val: platformNames,
92
+ });
93
+ } else {
94
+ for (const pName of platformNames) {
95
+ if (!_.isString(pName)) {
96
+ problems.push({
97
+ err: 'Incorrectly formatted platformName.',
98
+ val: pName,
99
+ });
100
+ }
101
+ }
102
+ }
103
+ }
104
+
105
+ if (!_.isString(automationName)) {
106
+ problems.push({
107
+ err: 'Missing or incorrect automationName',
108
+ val: automationName,
109
+ });
110
+ }
111
+
112
+ if (this.knownAutomationNames.has(automationName)) {
113
+ problems.push({
114
+ err: 'Multiple drivers claim support for the same automationName',
115
+ val: automationName,
116
+ });
117
+ }
118
+
119
+ // should we retain the name at the end of this function, once we've checked there are no problems?
120
+ this.knownAutomationNames.add(automationName);
121
+
122
+ return problems;
123
+ }
124
+
125
+ /**
126
+ * @param {ExtName<DriverType>} driverName
127
+ * @param {ExtManifest<DriverType>} extData
128
+ * @returns {string}
129
+ */
130
+ extensionDesc(driverName, {version, automationName}) {
131
+ return `${driverName}@${version} (automationName '${automationName}')`;
132
+ }
133
+
134
+ /**
135
+ * Given capabilities, find a matching driver within the config. Load its class and return it along with version and driver name.
136
+ * @template {import('@appium/types').StringRecord} C
137
+ * @param {C} caps
138
+ * @returns {MatchedDriver}
139
+ */
140
+ findMatchingDriver({automationName, platformName}) {
141
+ if (!_.isString(platformName)) {
142
+ throw new Error('You must include a platformName capability');
143
+ }
144
+
145
+ if (!_.isString(automationName)) {
146
+ throw new Error('You must include an automationName capability');
147
+ }
148
+
149
+ log.info(
150
+ `Attempting to find matching driver for automationName ` +
151
+ `'${automationName}' and platformName '${platformName}'`
152
+ );
153
+
154
+ try {
155
+ const {driverName, mainClass, version} = this._getDriverBySupport(
156
+ automationName,
157
+ platformName
158
+ );
159
+ log.info(`The '${driverName}' driver was installed and matched caps.`);
160
+ log.info(`Will require it at ${this.getInstallPath(driverName)}`);
161
+ const driver = this.require(driverName);
162
+ if (!driver) {
163
+ throw new Error(
164
+ `Driver '${driverName}' did not export a class with name '${mainClass}'. Contact the author of the driver!`
165
+ );
166
+ }
167
+ return {driver, version, driverName};
168
+ } catch (err) {
169
+ const msg =
170
+ `Could not find a driver for automationName ` +
171
+ `'${automationName}' and platformName '${platformName}'. ` +
172
+ `Have you installed a driver that supports those ` +
173
+ `capabilities? Run 'appium driver list --installed' to see. ` +
174
+ `(Lower-level error: ${err.message})`;
175
+ throw new Error(msg);
176
+ }
177
+ }
178
+
179
+ /**
180
+ * Given an automation name and platform name, find a suitable driver and return its extension data.
181
+ * @param {string} matchAutomationName
182
+ * @param {string} matchPlatformName
183
+ * @returns {ExtMetadata<DriverType> & import('appium/types').InternalMetadata & import('appium/types').CommonExtMetadata}
184
+ */
185
+ _getDriverBySupport(matchAutomationName, matchPlatformName) {
186
+ const drivers = this.installedExtensions;
187
+ for (const [driverName, driverData] of _.toPairs(drivers)) {
188
+ const {automationName, platformNames} = driverData;
189
+ const aNameMatches = automationName.toLowerCase() === matchAutomationName.toLowerCase();
190
+ const pNameMatches = _.includes(
191
+ platformNames.map(_.toLower),
192
+ matchPlatformName.toLowerCase()
193
+ );
194
+
195
+ if (aNameMatches && pNameMatches) {
196
+ return {driverName, ...driverData};
197
+ }
198
+
199
+ if (aNameMatches) {
200
+ throw new Error(
201
+ `Driver '${driverName}' supports automationName ` +
202
+ `'${automationName}', but Appium could not find ` +
203
+ `support for platformName '${matchPlatformName}'. Supported ` +
204
+ `platformNames are: ` +
205
+ JSON.stringify(platformNames)
206
+ );
207
+ }
208
+ }
209
+
210
+ throw new Error(`Could not find installed driver to support given caps`);
211
+ }
212
+ }
213
+
214
+ /**
215
+ * @template {ExtensionType} T
216
+ * @typedef {import('appium/types').ExtMetadata<T>} ExtMetadata
217
+ */
218
+
219
+ /**
220
+ * @template {ExtensionType} T
221
+ * @typedef {import('appium/types').ExtManifest<T>} ExtManifest
222
+ */
223
+
224
+ /**
225
+ * @typedef {import('@appium/types').ExtensionType} ExtensionType
226
+ * @typedef {import('appium/types').ManifestData} ManifestData
227
+ * @typedef {import('@appium/types').DriverType} DriverType
228
+ * @typedef {import('./manifest').Manifest} Manifest
229
+ */
230
+
231
+ /**
232
+ * @template {ExtensionType} T
233
+ * @typedef {import('appium/types').ExtRecord<T>} ExtRecord
234
+ */
235
+
236
+ /**
237
+ * @template {ExtensionType} T
238
+ * @typedef {import('appium/types').ExtName<T>} ExtName
239
+ */
240
+
241
+ /**
242
+ * Return value of {@linkcode DriverConfig.findMatchingDriver}
243
+ * @typedef MatchedDriver
244
+ * @property {import('@appium/types').DriverClass} driver
245
+ * @property {string} version
246
+ * @property {string} driverName
247
+ */