appium 2.0.0-beta.3 → 2.0.0-beta.30

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 (139) hide show
  1. package/README.md +10 -11
  2. package/build/lib/appium.d.ts +215 -0
  3. package/build/lib/appium.d.ts.map +1 -0
  4. package/build/lib/appium.js +238 -132
  5. package/build/lib/cli/args.d.ts +20 -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 +36 -0
  9. package/build/lib/cli/driver-command.d.ts.map +1 -0
  10. package/build/lib/cli/driver-command.js +19 -12
  11. package/build/lib/cli/extension-command.d.ts +345 -0
  12. package/build/lib/cli/extension-command.d.ts.map +1 -0
  13. package/build/lib/cli/extension-command.js +171 -96
  14. package/build/lib/cli/extension.d.ts +14 -0
  15. package/build/lib/cli/extension.d.ts.map +1 -0
  16. package/build/lib/cli/extension.js +31 -16
  17. package/build/lib/cli/parser.d.ts +79 -0
  18. package/build/lib/cli/parser.d.ts.map +1 -0
  19. package/build/lib/cli/parser.js +152 -95
  20. package/build/lib/cli/plugin-command.d.ts +39 -0
  21. package/build/lib/cli/plugin-command.d.ts.map +1 -0
  22. package/build/lib/cli/plugin-command.js +18 -13
  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 +40 -0
  30. package/build/lib/config.d.ts.map +1 -0
  31. package/build/lib/config.js +92 -67
  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 +84 -0
  36. package/build/lib/extension/driver-config.d.ts.map +1 -0
  37. package/build/lib/extension/driver-config.js +190 -0
  38. package/build/lib/extension/extension-config.d.ts +170 -0
  39. package/build/lib/extension/extension-config.d.ts.map +1 -0
  40. package/build/lib/extension/extension-config.js +297 -0
  41. package/build/lib/extension/index.d.ts +39 -0
  42. package/build/lib/extension/index.d.ts.map +1 -0
  43. package/build/lib/extension/index.js +77 -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 +246 -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 +68 -0
  50. package/build/lib/extension/plugin-config.d.ts +62 -0
  51. package/build/lib/extension/plugin-config.d.ts.map +1 -0
  52. package/build/lib/extension/plugin-config.js +87 -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 +12 -16
  62. package/build/lib/main.d.ts +51 -0
  63. package/build/lib/main.d.ts.map +1 -0
  64. package/build/lib/main.js +174 -82
  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 +180 -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 +452 -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/index.js +11 -0
  88. package/lib/appium-config.schema.json +278 -0
  89. package/lib/appium.js +398 -155
  90. package/lib/cli/args.js +174 -377
  91. package/lib/cli/driver-command.js +22 -7
  92. package/lib/cli/extension-command.js +372 -177
  93. package/lib/cli/extension.js +32 -10
  94. package/lib/cli/parser.js +252 -83
  95. package/lib/cli/plugin-command.js +19 -6
  96. package/lib/cli/utils.js +22 -2
  97. package/lib/config-file.js +223 -0
  98. package/lib/config.js +169 -69
  99. package/lib/constants.js +78 -0
  100. package/lib/extension/driver-config.js +249 -0
  101. package/lib/extension/extension-config.js +458 -0
  102. package/lib/extension/index.js +102 -0
  103. package/lib/extension/manifest.js +486 -0
  104. package/lib/extension/package-changed.js +63 -0
  105. package/lib/extension/plugin-config.js +113 -0
  106. package/lib/grid-register.js +25 -22
  107. package/lib/logger.js +1 -1
  108. package/lib/logsink.js +14 -7
  109. package/lib/main.js +233 -83
  110. package/lib/schema/arg-spec.js +232 -0
  111. package/lib/schema/cli-args.js +261 -0
  112. package/lib/schema/cli-transformers.js +122 -0
  113. package/lib/schema/index.js +2 -0
  114. package/lib/schema/keywords.js +134 -0
  115. package/lib/schema/schema.js +734 -0
  116. package/lib/utils.js +85 -129
  117. package/package.json +62 -85
  118. package/scripts/postinstall.js +71 -0
  119. package/types/appium-manifest.d.ts +61 -0
  120. package/types/cli.d.ts +134 -0
  121. package/types/extension.d.ts +56 -0
  122. package/types/external-manifest.d.ts +58 -0
  123. package/types/index.d.ts +7 -0
  124. package/CHANGELOG.md +0 -3515
  125. package/bin/ios-webkit-debug-proxy-launcher.js +0 -71
  126. package/build/lib/cli/npm.js +0 -206
  127. package/build/lib/cli/parser-helpers.js +0 -82
  128. package/build/lib/driver-config.js +0 -77
  129. package/build/lib/drivers.js +0 -96
  130. package/build/lib/extension-config.js +0 -251
  131. package/build/lib/plugin-config.js +0 -59
  132. package/build/lib/plugins.js +0 -14
  133. package/lib/cli/npm.js +0 -183
  134. package/lib/cli/parser-helpers.js +0 -79
  135. package/lib/driver-config.js +0 -46
  136. package/lib/drivers.js +0 -81
  137. package/lib/extension-config.js +0 -208
  138. package/lib/plugin-config.js +0 -34
  139. 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,208 +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 YAML from 'yaml';
6
-
7
- const DRIVER_TYPE = 'driver';
8
- const PLUGIN_TYPE = 'plugin';
9
- const DEFAULT_APPIUM_HOME = path.resolve(process.env.HOME, '.appium');
10
-
11
- const CONFIG_FILE_NAME = 'extensions.yaml';
12
- const CONFIG_SCHEMA_REV = 2;
13
-
14
- const INSTALL_TYPE_NPM = 'npm';
15
- const INSTALL_TYPE_LOCAL = 'local';
16
- const INSTALL_TYPE_GITHUB = 'github';
17
- const INSTALL_TYPE_GIT = 'git';
18
- const INSTALL_TYPES = [
19
- INSTALL_TYPE_GIT,
20
- INSTALL_TYPE_GITHUB,
21
- INSTALL_TYPE_LOCAL,
22
- INSTALL_TYPE_NPM
23
- ];
24
-
25
-
26
- export default class ExtensionConfig {
27
- constructor (appiumHome, extensionType, logFn = null) {
28
- if (logFn === null) {
29
- logFn = log.error.bind(log);
30
- }
31
- this.appiumHome = appiumHome;
32
- this.configFile = path.resolve(this.appiumHome, CONFIG_FILE_NAME);
33
- this.installedExtensions = {};
34
- this.extensionType = extensionType;
35
- this.configKey = `${extensionType}s`;
36
- this.yamlData = {[`${DRIVER_TYPE}s`]: {}, [`${PLUGIN_TYPE}s`]: {}};
37
- this.log = logFn;
38
- }
39
-
40
- validate (exts) {
41
- const foundProblems = {};
42
- for (const [extName, extData] of _.toPairs(exts)) {
43
- foundProblems[extName] = [
44
- ...this.getGenericConfigProblems(extData),
45
- ...this.getConfigProblems(extData)
46
- ];
47
- }
48
-
49
- const problemSummaries = [];
50
- for (const [extName, problems] of _.toPairs(foundProblems)) {
51
- if (_.isEmpty(problems)) {
52
- continue;
53
- }
54
- // remove this extension from the list since it's not valid
55
- delete exts[extName];
56
- problemSummaries.push(`${this.extensionType} ${extName} had errors and will not ` +
57
- `be available. Errors:`);
58
- for (const problem of problems) {
59
- problemSummaries.push(` - ${problem.err} (Actual value: ` +
60
- `${JSON.stringify(problem.val)})`);
61
- }
62
- }
63
-
64
- if (!_.isEmpty(problemSummaries)) {
65
- this.log(`Appium encountered one or more errors while validating ` +
66
- `the ${this.configKey} extension file (${this.configFile}):`);
67
- for (const summary of problemSummaries) {
68
- this.log(summary);
69
- }
70
- }
71
-
72
- return exts;
73
- }
74
-
75
- getGenericConfigProblems (ext) {
76
- const {version, pkgName, installSpec, installType, installPath, mainClass} = ext;
77
- const problems = [];
78
-
79
- if (!_.isString(version)) {
80
- problems.push({err: 'Missing or incorrect version', val: version});
81
- }
82
-
83
- if (!_.isString(pkgName)) {
84
- problems.push({err: 'Missing or incorrect NPM package name', val: pkgName});
85
- }
86
-
87
- if (!_.isString(installSpec)) {
88
- problems.push({err: 'Missing or incorrect installation spec', val: installSpec});
89
- }
90
-
91
- if (!_.includes(INSTALL_TYPES, installType)) {
92
- problems.push({err: 'Missing or incorrect install type', val: installType});
93
- }
94
-
95
- if (!_.isString(installPath)) {
96
- problems.push({err: 'Missing or incorrect installation path', val: installPath});
97
- }
98
-
99
- if (!_.isString(mainClass)) {
100
- problems.push({err: 'Missing or incorrect driver class name', val: mainClass});
101
- }
102
-
103
- return problems;
104
- }
105
-
106
- getConfigProblems (/*ext*/) {
107
- // shoud override this method if special validation is necessary for this extension type
108
- return [];
109
- }
110
-
111
- applySchemaMigrations () {
112
- if (this.yamlData.schemaRev < 2 && _.isUndefined(this.yamlData[PLUGIN_TYPE])) {
113
- // at schema revision 2, we started including plugins as well as drivers in the file,
114
- // so make sure we at least have an empty section for it
115
- this.yamlData[PLUGIN_TYPE] = {};
116
- }
117
- }
118
-
119
- async read () {
120
- await mkdirp(this.appiumHome); // ensure appium home exists
121
- try {
122
- this.yamlData = YAML.parse(await fs.readFile(this.configFile, 'utf8'));
123
- this.applySchemaMigrations();
124
-
125
- // set the list of drivers the user has installed
126
- this.installedExtensions = this.validate(this.yamlData[this.configKey]);
127
- } catch (err) {
128
- if (await fs.exists(this.configFile)) {
129
- // if the file exists and we couldn't parse it, that's a problem
130
- throw new Error(`Appium had trouble loading the extension installation ` +
131
- `cache file (${this.configFile}). Ensure it exists and is ` +
132
- `readable. Specific error: ${err.message}`);
133
- }
134
-
135
- // if the config file doesn't exist, try to write an empty one, to make
136
- // sure we actually have write privileges, and complain if we don't
137
- try {
138
- await this.write();
139
- } catch {
140
- throw new Error(`Appium could not read or write from the Appium Home directory ` +
141
- `(${this.appiumHome}). Please ensure it is writable.`);
142
- }
143
- }
144
- return this.installedExtensions;
145
- }
146
-
147
-
148
- async write () {
149
- const newYamlData = {
150
- ...this.yamlData,
151
- schemaRev: CONFIG_SCHEMA_REV,
152
- [this.configKey]: this.installedExtensions
153
- };
154
- await fs.writeFile(this.configFile, YAML.stringify(newYamlData), 'utf8');
155
- }
156
-
157
- async addExtension (extName, extData) {
158
- this.installedExtensions[extName] = extData;
159
- await this.write();
160
- }
161
-
162
- async removeExtension (extName) {
163
- delete this.installedExtensions[extName];
164
- await this.write();
165
- }
166
-
167
- print () {
168
- const extNames = Object.keys(this.installedExtensions);
169
- if (_.isEmpty(extNames)) {
170
- log.info(`No ${this.configKey} have been installed. Use the "appium ${this.extensionType}" ` +
171
- 'command to install the one(s) you want to use.');
172
- return;
173
- }
174
-
175
- log.info(`Available ${this.configKey}:`);
176
- for (const [extName, extData] of _.toPairs(this.installedExtensions)) {
177
- log.info(` - ${this.extensionDesc(extName, extData)}`);
178
- }
179
- }
180
-
181
- extensionDesc () {
182
- throw new Error('This must be implemented in a final class');
183
- }
184
-
185
- getExtensionRequirePath (extName) {
186
- const {pkgName, installPath} = this.installedExtensions[extName];
187
- return path.resolve(this.appiumHome, installPath, 'node_modules', pkgName);
188
- }
189
-
190
- getInstallPath (extName) {
191
- const {installPath} = this.installedExtensions[extName];
192
- return path.resolve(this.appiumHome, installPath);
193
- }
194
-
195
- require (extName) {
196
- const {mainClass} = this.installedExtensions[extName];
197
- return require(this.getExtensionRequirePath(extName))[mainClass];
198
- }
199
-
200
- isInstalled (extName) {
201
- return _.includes(Object.keys(this.installedExtensions), extName);
202
- }
203
- }
204
-
205
- export {
206
- INSTALL_TYPE_NPM, INSTALL_TYPE_GIT, INSTALL_TYPE_LOCAL, INSTALL_TYPE_GITHUB,
207
- INSTALL_TYPES, DEFAULT_APPIUM_HOME, DRIVER_TYPE, PLUGIN_TYPE,
208
- };
@@ -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
- };