appium 2.0.0-beta.35 → 2.0.0-beta.37

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