appium 2.0.0-beta.4 → 2.0.0-beta.42

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 (153) hide show
  1. package/README.md +10 -11
  2. package/build/lib/appium.d.ts +204 -0
  3. package/build/lib/appium.d.ts.map +1 -0
  4. package/build/lib/appium.js +256 -131
  5. package/build/lib/cli/args.d.ts +17 -0
  6. package/build/lib/cli/args.d.ts.map +1 -0
  7. package/build/lib/cli/args.js +96 -282
  8. package/build/lib/cli/driver-command.d.ts +37 -0
  9. package/build/lib/cli/driver-command.d.ts.map +1 -0
  10. package/build/lib/cli/driver-command.js +27 -18
  11. package/build/lib/cli/extension-command.d.ts +376 -0
  12. package/build/lib/cli/extension-command.d.ts.map +1 -0
  13. package/build/lib/cli/extension-command.js +287 -156
  14. package/build/lib/cli/extension.d.ts +22 -0
  15. package/build/lib/cli/extension.d.ts.map +1 -0
  16. package/build/lib/cli/extension.js +31 -17
  17. package/build/lib/cli/parser.d.ts +84 -0
  18. package/build/lib/cli/parser.d.ts.map +1 -0
  19. package/build/lib/cli/parser.js +164 -94
  20. package/build/lib/cli/plugin-command.d.ts +34 -0
  21. package/build/lib/cli/plugin-command.d.ts.map +1 -0
  22. package/build/lib/cli/plugin-command.js +26 -19
  23. package/build/lib/cli/utils.d.ts +29 -0
  24. package/build/lib/cli/utils.d.ts.map +1 -0
  25. package/build/lib/cli/utils.js +27 -3
  26. package/build/lib/config-file.d.ts +100 -0
  27. package/build/lib/config-file.d.ts.map +1 -0
  28. package/build/lib/config-file.js +136 -0
  29. package/build/lib/config.d.ts +49 -0
  30. package/build/lib/config.d.ts.map +1 -0
  31. package/build/lib/config.js +119 -96
  32. package/build/lib/constants.d.ts +48 -0
  33. package/build/lib/constants.d.ts.map +1 -0
  34. package/build/lib/constants.js +60 -0
  35. package/build/lib/extension/driver-config.d.ts +81 -0
  36. package/build/lib/extension/driver-config.d.ts.map +1 -0
  37. package/build/lib/extension/driver-config.js +177 -0
  38. package/build/lib/extension/extension-config.d.ts +242 -0
  39. package/build/lib/extension/extension-config.d.ts.map +1 -0
  40. package/build/lib/extension/extension-config.js +436 -0
  41. package/build/lib/extension/index.d.ts +48 -0
  42. package/build/lib/extension/index.d.ts.map +1 -0
  43. package/build/lib/extension/index.js +75 -0
  44. package/build/lib/extension/manifest.d.ts +174 -0
  45. package/build/lib/extension/manifest.d.ts.map +1 -0
  46. package/build/lib/extension/manifest.js +256 -0
  47. package/build/lib/extension/package-changed.d.ts +11 -0
  48. package/build/lib/extension/package-changed.d.ts.map +1 -0
  49. package/build/lib/extension/package-changed.js +66 -0
  50. package/build/lib/extension/plugin-config.d.ts +57 -0
  51. package/build/lib/extension/plugin-config.d.ts.map +1 -0
  52. package/build/lib/extension/plugin-config.js +78 -0
  53. package/build/lib/grid-register.d.ts +10 -0
  54. package/build/lib/grid-register.d.ts.map +1 -0
  55. package/build/lib/grid-register.js +21 -25
  56. package/build/lib/logger.d.ts +3 -0
  57. package/build/lib/logger.d.ts.map +1 -0
  58. package/build/lib/logger.js +4 -6
  59. package/build/lib/logsink.d.ts +4 -0
  60. package/build/lib/logsink.d.ts.map +1 -0
  61. package/build/lib/logsink.js +14 -17
  62. package/build/lib/main.d.ts +55 -0
  63. package/build/lib/main.d.ts.map +1 -0
  64. package/build/lib/main.js +183 -91
  65. package/build/lib/schema/arg-spec.d.ts +143 -0
  66. package/build/lib/schema/arg-spec.d.ts.map +1 -0
  67. package/build/lib/schema/arg-spec.js +119 -0
  68. package/build/lib/schema/cli-args.d.ts +19 -0
  69. package/build/lib/schema/cli-args.d.ts.map +1 -0
  70. package/build/lib/schema/cli-args.js +178 -0
  71. package/build/lib/schema/cli-transformers.d.ts +5 -0
  72. package/build/lib/schema/cli-transformers.d.ts.map +1 -0
  73. package/build/lib/schema/cli-transformers.js +74 -0
  74. package/build/lib/schema/index.d.ts +3 -0
  75. package/build/lib/schema/index.d.ts.map +1 -0
  76. package/build/lib/schema/index.js +34 -0
  77. package/build/lib/schema/keywords.d.ts +24 -0
  78. package/build/lib/schema/keywords.d.ts.map +1 -0
  79. package/build/lib/schema/keywords.js +70 -0
  80. package/build/lib/schema/schema.d.ts +259 -0
  81. package/build/lib/schema/schema.d.ts.map +1 -0
  82. package/build/lib/schema/schema.js +450 -0
  83. package/build/lib/utils.d.ts +66 -0
  84. package/build/lib/utils.d.ts.map +1 -0
  85. package/build/lib/utils.js +35 -139
  86. package/build/tsconfig.tsbuildinfo +1 -0
  87. package/build/types/appium-manifest.d.ts +59 -0
  88. package/build/types/appium-manifest.d.ts.map +1 -0
  89. package/build/types/cli.d.ts +123 -0
  90. package/build/types/cli.d.ts.map +1 -0
  91. package/build/types/extension-manifest.d.ts +55 -0
  92. package/build/types/extension-manifest.d.ts.map +1 -0
  93. package/build/types/index.d.ts +16 -0
  94. package/build/types/index.d.ts.map +1 -0
  95. package/driver.d.ts +1 -0
  96. package/driver.js +14 -0
  97. package/index.js +11 -0
  98. package/lib/appium.js +520 -186
  99. package/lib/cli/args.js +267 -422
  100. package/lib/cli/driver-command.js +58 -23
  101. package/lib/cli/extension-command.js +613 -260
  102. package/lib/cli/extension.js +47 -17
  103. package/lib/cli/parser.js +263 -83
  104. package/lib/cli/plugin-command.js +48 -20
  105. package/lib/cli/utils.js +24 -10
  106. package/lib/config-file.js +219 -0
  107. package/lib/config.js +243 -110
  108. package/lib/constants.js +69 -0
  109. package/lib/extension/driver-config.js +249 -0
  110. package/lib/extension/extension-config.js +677 -0
  111. package/lib/extension/index.js +116 -0
  112. package/lib/extension/manifest.js +475 -0
  113. package/lib/extension/package-changed.js +64 -0
  114. package/lib/extension/plugin-config.js +113 -0
  115. package/lib/grid-register.js +49 -35
  116. package/lib/logger.js +1 -2
  117. package/lib/logsink.js +38 -33
  118. package/lib/main.js +308 -100
  119. package/lib/schema/arg-spec.js +229 -0
  120. package/lib/schema/cli-args.js +238 -0
  121. package/lib/schema/cli-transformers.js +115 -0
  122. package/lib/schema/index.js +2 -0
  123. package/lib/schema/keywords.js +136 -0
  124. package/lib/schema/schema.js +717 -0
  125. package/lib/utils.js +121 -140
  126. package/package.json +85 -85
  127. package/plugin.d.ts +1 -0
  128. package/plugin.js +13 -0
  129. package/scripts/autoinstall-extensions.js +185 -0
  130. package/support.d.ts +1 -0
  131. package/support.js +13 -0
  132. package/test.d.ts +7 -0
  133. package/test.js +13 -0
  134. package/types/appium-manifest.ts +73 -0
  135. package/types/cli.ts +150 -0
  136. package/types/extension-manifest.ts +64 -0
  137. package/types/index.ts +21 -0
  138. package/CHANGELOG.md +0 -3515
  139. package/bin/ios-webkit-debug-proxy-launcher.js +0 -71
  140. package/build/lib/cli/npm.js +0 -206
  141. package/build/lib/cli/parser-helpers.js +0 -82
  142. package/build/lib/driver-config.js +0 -77
  143. package/build/lib/drivers.js +0 -96
  144. package/build/lib/extension-config.js +0 -253
  145. package/build/lib/plugin-config.js +0 -59
  146. package/build/lib/plugins.js +0 -14
  147. package/lib/cli/npm.js +0 -183
  148. package/lib/cli/parser-helpers.js +0 -79
  149. package/lib/driver-config.js +0 -46
  150. package/lib/drivers.js +0 -81
  151. package/lib/extension-config.js +0 -209
  152. package/lib/plugin-config.js +0 -34
  153. package/lib/plugins.js +0 -10
package/lib/drivers.js DELETED
@@ -1,81 +0,0 @@
1
- import _ from 'lodash';
2
- import log from './logger';
3
-
4
-
5
- // This is a map of driver names to npm packages representing those drivers.
6
- // The drivers in this list will be available to the CLI so users can just
7
- // type 'appium driver install 'name'', rather than having to specify the full
8
- // npm package. I.e., these are the officially recognized drivers.
9
- const KNOWN_DRIVERS = {
10
- uiautomator2: 'appium-uiautomator2-driver',
11
- xcuitest: 'appium-xcuitest-driver',
12
- youiengine: 'appium-youiengine-driver',
13
- windows: 'appium-windows-driver',
14
- mac: 'appium-mac-driver',
15
- espresso: 'appium-espresso-driver',
16
- tizen: 'appium-tizen-driver',
17
- flutter: 'appium-flutter-driver',
18
- };
19
-
20
- function getDriverBySupport (drivers, matchAutomationName, matchPlatformName) {
21
- for (const [driverName, driverData] of _.toPairs(drivers)) {
22
- const {automationName, platformNames} = driverData;
23
- const aNameMatches = automationName.toLowerCase() === matchAutomationName.toLowerCase();
24
- const pNameMatches = _.includes(platformNames.map(_.toLower),
25
- matchPlatformName.toLowerCase());
26
-
27
- if (aNameMatches && pNameMatches) {
28
- return {driverName, ...driverData};
29
- }
30
-
31
- if (aNameMatches) {
32
- throw new Error(`Driver '${driverName}' supports automationName ` +
33
- `'${automationName}', but Appium could not find ` +
34
- `support for platformName '${matchPlatformName}'. Supported ` +
35
- `platformNames are: ` +
36
- JSON.stringify(platformNames));
37
- }
38
- }
39
-
40
- throw new Error(`Could not find installed driver to support given caps`);
41
- }
42
-
43
- function findMatchingDriver (config, {automationName, platformName}) {
44
- if (!_.isString(platformName)) {
45
- throw new Error('You must include a platformName capability');
46
- }
47
-
48
- if (!_.isString(automationName)) {
49
- throw new Error('You must include an automationName capability');
50
- }
51
-
52
- log.info(`Attempting to find matching driver for automationName ` +
53
- `'${automationName}' and platformName '${platformName}'`);
54
-
55
- try {
56
- const {
57
- driverName,
58
- mainClass,
59
- version,
60
- } = getDriverBySupport(config.installedExtensions, automationName, platformName);
61
- log.info(`The '${driverName}' driver was installed and matched caps.`);
62
- log.info(`Will require it at ${config.getExtensionRequirePath(driverName)}`);
63
- const driver = config.require(driverName);
64
- if (!driver) {
65
- throw new Error(`MainClass ${mainClass} did not result in a driver object`);
66
- }
67
- return {driver, version};
68
- } catch (err) {
69
- const msg = `Could not find a driver for automationName ` +
70
- `'${automationName}' and platformName ${platformName}'. ` +
71
- `Have you installed a driver that supports those ` +
72
- `capabilities? Run 'appium driver list --installed' to see. ` +
73
- `(Lower-level error: ${err.message})`;
74
- throw new Error(msg);
75
- }
76
- }
77
-
78
- export {
79
- findMatchingDriver,
80
- KNOWN_DRIVERS,
81
- };
@@ -1,209 +0,0 @@
1
- import _ from 'lodash';
2
- import log from './logger';
3
- import { fs, mkdirp } from 'appium-support';
4
- import path from 'path';
5
- import os from 'os';
6
- import YAML from 'yaml';
7
-
8
- const DRIVER_TYPE = 'driver';
9
- const PLUGIN_TYPE = 'plugin';
10
- const DEFAULT_APPIUM_HOME = os.homedir();
11
-
12
- const CONFIG_FILE_NAME = 'extensions.yaml';
13
- const CONFIG_SCHEMA_REV = 2;
14
-
15
- const INSTALL_TYPE_NPM = 'npm';
16
- const INSTALL_TYPE_LOCAL = 'local';
17
- const INSTALL_TYPE_GITHUB = 'github';
18
- const INSTALL_TYPE_GIT = 'git';
19
- const INSTALL_TYPES = [
20
- INSTALL_TYPE_GIT,
21
- INSTALL_TYPE_GITHUB,
22
- INSTALL_TYPE_LOCAL,
23
- INSTALL_TYPE_NPM
24
- ];
25
-
26
-
27
- export default class ExtensionConfig {
28
- constructor (appiumHome, extensionType, logFn = null) {
29
- if (logFn === null) {
30
- logFn = log.error.bind(log);
31
- }
32
- this.appiumHome = appiumHome;
33
- this.configFile = path.resolve(this.appiumHome, CONFIG_FILE_NAME);
34
- this.installedExtensions = {};
35
- this.extensionType = extensionType;
36
- this.configKey = `${extensionType}s`;
37
- this.yamlData = {[`${DRIVER_TYPE}s`]: {}, [`${PLUGIN_TYPE}s`]: {}};
38
- this.log = logFn;
39
- }
40
-
41
- validate (exts) {
42
- const foundProblems = {};
43
- for (const [extName, extData] of _.toPairs(exts)) {
44
- foundProblems[extName] = [
45
- ...this.getGenericConfigProblems(extData),
46
- ...this.getConfigProblems(extData)
47
- ];
48
- }
49
-
50
- const problemSummaries = [];
51
- for (const [extName, problems] of _.toPairs(foundProblems)) {
52
- if (_.isEmpty(problems)) {
53
- continue;
54
- }
55
- // remove this extension from the list since it's not valid
56
- delete exts[extName];
57
- problemSummaries.push(`${this.extensionType} ${extName} had errors and will not ` +
58
- `be available. Errors:`);
59
- for (const problem of problems) {
60
- problemSummaries.push(` - ${problem.err} (Actual value: ` +
61
- `${JSON.stringify(problem.val)})`);
62
- }
63
- }
64
-
65
- if (!_.isEmpty(problemSummaries)) {
66
- this.log(`Appium encountered one or more errors while validating ` +
67
- `the ${this.configKey} extension file (${this.configFile}):`);
68
- for (const summary of problemSummaries) {
69
- this.log(summary);
70
- }
71
- }
72
-
73
- return exts;
74
- }
75
-
76
- getGenericConfigProblems (ext) {
77
- const {version, pkgName, installSpec, installType, installPath, mainClass} = ext;
78
- const problems = [];
79
-
80
- if (!_.isString(version)) {
81
- problems.push({err: 'Missing or incorrect version', val: version});
82
- }
83
-
84
- if (!_.isString(pkgName)) {
85
- problems.push({err: 'Missing or incorrect NPM package name', val: pkgName});
86
- }
87
-
88
- if (!_.isString(installSpec)) {
89
- problems.push({err: 'Missing or incorrect installation spec', val: installSpec});
90
- }
91
-
92
- if (!_.includes(INSTALL_TYPES, installType)) {
93
- problems.push({err: 'Missing or incorrect install type', val: installType});
94
- }
95
-
96
- if (!_.isString(installPath)) {
97
- problems.push({err: 'Missing or incorrect installation path', val: installPath});
98
- }
99
-
100
- if (!_.isString(mainClass)) {
101
- problems.push({err: 'Missing or incorrect driver class name', val: mainClass});
102
- }
103
-
104
- return problems;
105
- }
106
-
107
- getConfigProblems (/*ext*/) {
108
- // shoud override this method if special validation is necessary for this extension type
109
- return [];
110
- }
111
-
112
- applySchemaMigrations () {
113
- if (this.yamlData.schemaRev < 2 && _.isUndefined(this.yamlData[PLUGIN_TYPE])) {
114
- // at schema revision 2, we started including plugins as well as drivers in the file,
115
- // so make sure we at least have an empty section for it
116
- this.yamlData[PLUGIN_TYPE] = {};
117
- }
118
- }
119
-
120
- async read () {
121
- await mkdirp(this.appiumHome); // ensure appium home exists
122
- try {
123
- this.yamlData = YAML.parse(await fs.readFile(this.configFile, 'utf8'));
124
- this.applySchemaMigrations();
125
-
126
- // set the list of drivers the user has installed
127
- this.installedExtensions = this.validate(this.yamlData[this.configKey]);
128
- } catch (err) {
129
- if (await fs.exists(this.configFile)) {
130
- // if the file exists and we couldn't parse it, that's a problem
131
- throw new Error(`Appium had trouble loading the extension installation ` +
132
- `cache file (${this.configFile}). Ensure it exists and is ` +
133
- `readable. Specific error: ${err.message}`);
134
- }
135
-
136
- // if the config file doesn't exist, try to write an empty one, to make
137
- // sure we actually have write privileges, and complain if we don't
138
- try {
139
- await this.write();
140
- } catch {
141
- throw new Error(`Appium could not read or write from the Appium Home directory ` +
142
- `(${this.appiumHome}). Please ensure it is writable.`);
143
- }
144
- }
145
- return this.installedExtensions;
146
- }
147
-
148
-
149
- async write () {
150
- const newYamlData = {
151
- ...this.yamlData,
152
- schemaRev: CONFIG_SCHEMA_REV,
153
- [this.configKey]: this.installedExtensions
154
- };
155
- await fs.writeFile(this.configFile, YAML.stringify(newYamlData), 'utf8');
156
- }
157
-
158
- async addExtension (extName, extData) {
159
- this.installedExtensions[extName] = extData;
160
- await this.write();
161
- }
162
-
163
- async removeExtension (extName) {
164
- delete this.installedExtensions[extName];
165
- await this.write();
166
- }
167
-
168
- print () {
169
- const extNames = Object.keys(this.installedExtensions);
170
- if (_.isEmpty(extNames)) {
171
- log.info(`No ${this.configKey} have been installed. Use the "appium ${this.extensionType}" ` +
172
- 'command to install the one(s) you want to use.');
173
- return;
174
- }
175
-
176
- log.info(`Available ${this.configKey}:`);
177
- for (const [extName, extData] of _.toPairs(this.installedExtensions)) {
178
- log.info(` - ${this.extensionDesc(extName, extData)}`);
179
- }
180
- }
181
-
182
- extensionDesc () {
183
- throw new Error('This must be implemented in a final class');
184
- }
185
-
186
- getExtensionRequirePath (extName) {
187
- const {pkgName, installPath} = this.installedExtensions[extName];
188
- return path.resolve(this.appiumHome, installPath, 'node_modules', pkgName);
189
- }
190
-
191
- getInstallPath (extName) {
192
- const {installPath} = this.installedExtensions[extName];
193
- return path.resolve(this.appiumHome, installPath);
194
- }
195
-
196
- require (extName) {
197
- const {mainClass} = this.installedExtensions[extName];
198
- return require(this.getExtensionRequirePath(extName))[mainClass];
199
- }
200
-
201
- isInstalled (extName) {
202
- return _.includes(Object.keys(this.installedExtensions), extName);
203
- }
204
- }
205
-
206
- export {
207
- INSTALL_TYPE_NPM, INSTALL_TYPE_GIT, INSTALL_TYPE_LOCAL, INSTALL_TYPE_GITHUB,
208
- INSTALL_TYPES, DEFAULT_APPIUM_HOME, DRIVER_TYPE, PLUGIN_TYPE,
209
- };
@@ -1,34 +0,0 @@
1
- import _ from 'lodash';
2
- import ExtensionConfig, { PLUGIN_TYPE } from './extension-config';
3
- import log from './logger';
4
-
5
- export default class PluginConfig extends ExtensionConfig {
6
- constructor (appiumHome, logFn = null) {
7
- super(appiumHome, PLUGIN_TYPE, logFn);
8
- }
9
-
10
- extensionDesc (pluginName, {version}) {
11
- return `${pluginName}@${version}`;
12
- }
13
-
14
- print (activePlugins) {
15
- const pluginNames = Object.keys(this.installedExtensions);
16
- const activeNames = activePlugins.map((p) => p.name);
17
-
18
- if (_.isEmpty(pluginNames)) {
19
- log.info(`No plugins have been installed. Use the "appium plugin" ` +
20
- 'command to install the one(s) you want to use.');
21
- return;
22
- }
23
-
24
- log.info(`Available plugins:`);
25
- for (const [pluginName, pluginData] of _.toPairs(this.installedExtensions)) {
26
- const activeTxt = _.includes(activeNames, pluginName) ? ' (ACTIVE)' : '';
27
- log.info(` - ${this.extensionDesc(pluginName, pluginData)}${activeTxt}`);
28
- }
29
-
30
- if (_.isEmpty(activePlugins)) {
31
- log.info('No plugins activated. Use the --plugins flag with names of plugins to activate');
32
- }
33
- }
34
- }
package/lib/plugins.js DELETED
@@ -1,10 +0,0 @@
1
- // This is a map of plugin names to npm packages representing those plugins.
2
- // The plugins in this list will be available to the CLI so users can just
3
- // type 'appium plugin install 'name'', rather than having to specify the full
4
- // npm package. I.e., these are the officially recognized plugins.
5
- const KNOWN_PLUGINS = {
6
- };
7
-
8
- export {
9
- KNOWN_PLUGINS,
10
- };