appium 2.0.0-beta.35 → 2.0.0-beta.39

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
package/lib/config.js CHANGED
@@ -1,12 +1,12 @@
1
1
  /* eslint-disable no-console */
2
2
  import _ from 'lodash';
3
- import { system, fs } from '@appium/support';
3
+ import {system, fs} from '@appium/support';
4
4
  import axios from 'axios';
5
- import { exec } from 'teen_process';
5
+ import {exec} from 'teen_process';
6
6
  import logger from './logger';
7
7
  import semver from 'semver';
8
8
  import findUp from 'find-up';
9
- import { getDefaultsForSchema, getAllArgSpecs } from './schema/schema';
9
+ import {getDefaultsForSchema, getAllArgSpecs} from './schema/schema';
10
10
 
11
11
  const npmPackage = fs.readPackageJsonFrom(__dirname);
12
12
 
@@ -18,17 +18,17 @@ const GIT_BINARY = `git${system.isWindows() ? '.exe' : ''}`;
18
18
  const GITHUB_API = 'https://api.github.com/repos/appium/appium';
19
19
 
20
20
  /**
21
- * @type {import('../types/cli').BuildInfo}
21
+ * @type {import('appium/types').BuildInfo}
22
22
  */
23
23
  const BUILD_INFO = {
24
24
  version: APPIUM_VER,
25
25
  };
26
26
 
27
- function getNodeVersion () {
28
- return /** @type {import('semver').SemVer} */(semver.coerce(process.version));
27
+ function getNodeVersion() {
28
+ return /** @type {import('semver').SemVer} */ (semver.coerce(process.version));
29
29
  }
30
30
 
31
- async function updateBuildInfo (useGithubApiFallback = false) {
31
+ async function updateBuildInfo(useGithubApiFallback = false) {
32
32
  const sha = await getGitRev(useGithubApiFallback);
33
33
  if (!sha) {
34
34
  return;
@@ -47,16 +47,16 @@ async function updateBuildInfo (useGithubApiFallback = false) {
47
47
  * directory. Monorepos, see?
48
48
  * @returns {Promise<string|undefined>} Path to dir or `undefined` if not found
49
49
  */
50
- async function findGitRoot () {
50
+ async function findGitRoot() {
51
51
  return await findUp(GIT_META_ROOT, {cwd: rootDir, type: 'directory'});
52
52
  }
53
53
 
54
- async function getGitRev (useGithubApiFallback = false) {
54
+ async function getGitRev(useGithubApiFallback = false) {
55
55
  const gitRoot = await findGitRoot();
56
56
  if (gitRoot) {
57
57
  try {
58
58
  const {stdout} = await exec(GIT_BINARY, ['rev-parse', 'HEAD'], {
59
- cwd: gitRoot
59
+ cwd: gitRoot,
60
60
  });
61
61
  return stdout.trim();
62
62
  } catch (ign) {}
@@ -67,11 +67,13 @@ async function getGitRev (useGithubApiFallback = false) {
67
67
  }
68
68
 
69
69
  try {
70
- const resBodyObj = (await axios.get(`${GITHUB_API}/tags`, {
71
- headers: {
72
- 'User-Agent': `Appium ${APPIUM_VER}`
73
- }
74
- })).data;
70
+ const resBodyObj = (
71
+ await axios.get(`${GITHUB_API}/tags`, {
72
+ headers: {
73
+ 'User-Agent': `Appium ${APPIUM_VER}`,
74
+ },
75
+ })
76
+ ).data;
75
77
  if (_.isArray(resBodyObj)) {
76
78
  for (const {name, commit} of resBodyObj) {
77
79
  if (name === `v${APPIUM_VER}` && commit && commit.sha) {
@@ -88,12 +90,12 @@ async function getGitRev (useGithubApiFallback = false) {
88
90
  * @param {boolean} [useGithubApiFallback]
89
91
  * @returns {Promise<string?>}
90
92
  */
91
- async function getGitTimestamp (commitSha, useGithubApiFallback = false) {
93
+ async function getGitTimestamp(commitSha, useGithubApiFallback = false) {
92
94
  const gitRoot = await findGitRoot();
93
95
  if (gitRoot) {
94
96
  try {
95
97
  const {stdout} = await exec(GIT_BINARY, ['show', '-s', '--format=%ci', commitSha], {
96
- cwd: gitRoot
98
+ cwd: gitRoot,
97
99
  });
98
100
  return stdout.trim();
99
101
  } catch (ign) {}
@@ -104,11 +106,13 @@ async function getGitTimestamp (commitSha, useGithubApiFallback = false) {
104
106
  }
105
107
 
106
108
  try {
107
- const resBodyObj = (await axios.get(`${GITHUB_API}/commits/${commitSha}`, {
108
- headers: {
109
- 'User-Agent': `Appium ${APPIUM_VER}`
110
- }
111
- })).data;
109
+ const resBodyObj = (
110
+ await axios.get(`${GITHUB_API}/commits/${commitSha}`, {
111
+ headers: {
112
+ 'User-Agent': `Appium ${APPIUM_VER}`,
113
+ },
114
+ })
115
+ ).data;
112
116
  if (resBodyObj && resBodyObj.commit) {
113
117
  if (resBodyObj.commit.committer && resBodyObj.commit.committer.date) {
114
118
  return resBodyObj.commit.committer.date;
@@ -126,25 +130,24 @@ async function getGitTimestamp (commitSha, useGithubApiFallback = false) {
126
130
  * only contains the Appium version, but is updated with the build timestamp
127
131
  * and git commit hash asynchronously as soon as `updateBuildInfo` is called
128
132
  * and succeeds.
129
- * @returns {import('../types/cli').BuildInfo}
133
+ * @returns {import('appium/types').BuildInfo}
130
134
  */
131
- function getBuildInfo () {
135
+ function getBuildInfo() {
132
136
  return BUILD_INFO;
133
137
  }
134
138
 
135
- function checkNodeOk () {
139
+ function checkNodeOk() {
136
140
  const version = getNodeVersion();
137
141
  if (!semver.satisfies(version, MIN_NODE_VERSION)) {
138
142
  logger.errorAndThrow(`Node version must be ${MIN_NODE_VERSION}. Currently ${version.version}`);
139
143
  }
140
144
  }
141
145
 
142
- function warnNodeDeprecations () {
146
+ function warnNodeDeprecations() {
143
147
  /**
144
148
  * Uncomment this section to get node version deprecation warnings
145
149
  * Also add test cases to config-specs.js to cover the cases added
146
150
  **/
147
-
148
151
  // const version = getNodeVersion();
149
152
  // if (version.major < 8) {
150
153
  // logger.warn(`Appium support for versions of node < ${version.major} has been ` +
@@ -153,7 +156,7 @@ function warnNodeDeprecations () {
153
156
  // }
154
157
  }
155
158
 
156
- async function showBuildInfo () {
159
+ async function showBuildInfo() {
157
160
  await updateBuildInfo(true);
158
161
  console.log(JSON.stringify(getBuildInfo())); // eslint-disable-line no-console
159
162
  }
@@ -163,7 +166,7 @@ async function showBuildInfo () {
163
166
  * @param {Args} parsedArgs
164
167
  * @returns {Args}
165
168
  */
166
- function getNonDefaultServerArgs (parsedArgs) {
169
+ function getNonDefaultServerArgs(parsedArgs) {
167
170
  /**
168
171
  * Flattens parsed args into a single level object for comparison with
169
172
  * flattened defaults across server args and extension args.
@@ -172,12 +175,16 @@ function getNonDefaultServerArgs (parsedArgs) {
172
175
  */
173
176
  const flatten = (args) => {
174
177
  const argSpecs = getAllArgSpecs();
175
- const flattened = _.reduce([...argSpecs.values()], (acc, argSpec) => {
176
- if (_.has(args, argSpec.dest)) {
177
- acc[argSpec.dest] = {value: _.get(args, argSpec.dest), argSpec};
178
- }
179
- return acc;
180
- }, /** @type {Record<string, { value: any, argSpec: ArgSpec }>} */({}));
178
+ const flattened = _.reduce(
179
+ [...argSpecs.values()],
180
+ (acc, argSpec) => {
181
+ if (_.has(args, argSpec.dest)) {
182
+ acc[argSpec.dest] = {value: _.get(args, argSpec.dest), argSpec};
183
+ }
184
+ return acc;
185
+ },
186
+ /** @type {Record<string, { value: any, argSpec: ArgSpec }>} */ ({})
187
+ );
181
188
 
182
189
  return flattened;
183
190
  };
@@ -185,27 +192,30 @@ function getNonDefaultServerArgs (parsedArgs) {
185
192
  const args = flatten(parsedArgs);
186
193
 
187
194
  // hopefully these function names are descriptive enough
188
- const typesDiffer = /** @param {string} dest */(dest) => typeof args[dest].value !== typeof defaultsFromSchema[dest];
195
+ const typesDiffer = /** @param {string} dest */ (dest) =>
196
+ typeof args[dest].value !== typeof defaultsFromSchema[dest];
189
197
 
190
- const defaultValueIsArray = /** @param {string} dest */(dest) => _.isArray(defaultsFromSchema[dest]);
198
+ const defaultValueIsArray = /** @param {string} dest */ (dest) =>
199
+ _.isArray(defaultsFromSchema[dest]);
191
200
 
192
- const argsValueIsArray = /** @param {string} dest */(dest) => _.isArray(args[dest].value);
201
+ const argsValueIsArray = /** @param {string} dest */ (dest) => _.isArray(args[dest].value);
193
202
 
194
- const arraysDiffer = /** @param {string} dest */(dest) => _.gt(_.size(_.difference(args[dest].value, defaultsFromSchema[dest])), 0);
203
+ const arraysDiffer = /** @param {string} dest */ (dest) =>
204
+ _.gt(_.size(_.difference(args[dest].value, defaultsFromSchema[dest])), 0);
195
205
 
196
- const valuesDiffer = /** @param {string} dest */(dest) => args[dest].value !== defaultsFromSchema[dest];
206
+ const valuesDiffer = /** @param {string} dest */ (dest) =>
207
+ args[dest].value !== defaultsFromSchema[dest];
197
208
 
198
- const defaultIsDefined = /** @param {string} dest */(dest) => !_.isUndefined(defaultsFromSchema[dest]);
209
+ const defaultIsDefined = /** @param {string} dest */ (dest) =>
210
+ !_.isUndefined(defaultsFromSchema[dest]);
199
211
 
200
212
  // note that `_.overEvery` is like an "AND", and `_.overSome` is like an "OR"
201
213
 
202
- const argValueNotArrayOrArraysDiffer = _.overSome([
203
- _.negate(argsValueIsArray),
204
- arraysDiffer
205
- ]);
214
+ const argValueNotArrayOrArraysDiffer = _.overSome([_.negate(argsValueIsArray), arraysDiffer]);
206
215
 
207
216
  const defaultValueNotArrayAndValuesDiffer = _.overEvery([
208
- _.negate(defaultValueIsArray), valuesDiffer
217
+ _.negate(defaultValueIsArray),
218
+ valuesDiffer,
209
219
  ]);
210
220
 
211
221
  /**
@@ -224,12 +234,9 @@ function getNonDefaultServerArgs (parsedArgs) {
224
234
  defaultIsDefined,
225
235
  _.overSome([
226
236
  typesDiffer,
227
- _.overEvery([
228
- defaultValueIsArray,
229
- argValueNotArrayOrArraysDiffer
230
- ]),
231
- defaultValueNotArrayAndValuesDiffer
232
- ])
237
+ _.overEvery([defaultValueIsArray, argValueNotArrayOrArraysDiffer]),
238
+ defaultValueNotArrayAndValuesDiffer,
239
+ ]),
233
240
  ]);
234
241
 
235
242
  const defaultsFromSchema = getDefaultsForSchema(true);
@@ -237,7 +244,8 @@ function getNonDefaultServerArgs (parsedArgs) {
237
244
  return _.reduce(
238
245
  _.pickBy(args, (__, key) => isNotDefault(key)),
239
246
  // explodes the flattened object back into nested one
240
- (acc, {value, argSpec}) => _.set(acc, argSpec.dest, value), /** @type {Args} */({})
247
+ (acc, {value, argSpec}) => _.set(acc, argSpec.dest, value),
248
+ /** @type {Args} */ ({})
241
249
  );
242
250
  }
243
251
 
@@ -251,7 +259,8 @@ function getNonDefaultServerArgs (parsedArgs) {
251
259
  const compactConfig = _.partial(
252
260
  _.omitBy,
253
261
  _,
254
- (value, key) => key === 'subcommand' || _.isUndefined(value) || (_.isObject(value) && _.isEmpty(value))
262
+ (value, key) =>
263
+ key === 'subcommand' || _.isUndefined(value) || (_.isObject(value) && _.isEmpty(value))
255
264
  );
256
265
 
257
266
  /**
@@ -265,7 +274,7 @@ const compactConfig = _.partial(
265
274
  * @param {Partial<ParsedArgs>} defaults - Configuration defaults from schemas
266
275
  * @param {ParsedArgs} parsedArgs - Entire parsed args object
267
276
  */
268
- function showConfig (nonDefaultPreConfigParsedArgs, configResult, defaults, parsedArgs) {
277
+ function showConfig(nonDefaultPreConfigParsedArgs, configResult, defaults, parsedArgs) {
269
278
  console.log('Appium Configuration\n');
270
279
  console.log('from defaults:\n');
271
280
  console.dir(compactConfig(defaults));
@@ -288,26 +297,35 @@ function showConfig (nonDefaultPreConfigParsedArgs, configResult, defaults, pars
288
297
  /**
289
298
  * @param {string} tmpDir
290
299
  */
291
- async function validateTmpDir (tmpDir) {
300
+ async function validateTmpDir(tmpDir) {
292
301
  try {
293
302
  await fs.mkdirp(tmpDir);
294
303
  } catch (e) {
295
- throw new Error(`We could not ensure that the temp dir you specified ` +
296
- `(${tmpDir}) exists. Please make sure it's writeable.`);
304
+ throw new Error(
305
+ `We could not ensure that the temp dir you specified ` +
306
+ `(${tmpDir}) exists. Please make sure it's writeable.`
307
+ );
297
308
  }
298
309
  }
299
310
 
300
311
  const rootDir = fs.findRoot(__dirname);
301
312
 
302
313
  export {
303
- getBuildInfo, checkNodeOk, showBuildInfo,
304
- warnNodeDeprecations, validateTmpDir, getNonDefaultServerArgs,
305
- getGitRev, APPIUM_VER, updateBuildInfo, showConfig, rootDir
314
+ getBuildInfo,
315
+ checkNodeOk,
316
+ showBuildInfo,
317
+ warnNodeDeprecations,
318
+ validateTmpDir,
319
+ getNonDefaultServerArgs,
320
+ getGitRev,
321
+ APPIUM_VER,
322
+ updateBuildInfo,
323
+ showConfig,
324
+ rootDir,
306
325
  };
307
326
 
308
327
  /**
309
- * @typedef {import('../types').ParsedArgs} ParsedArgs
310
- * @typedef {import('../types').Args} Args
328
+ * @typedef {import('appium/types').ParsedArgs} ParsedArgs
329
+ * @typedef {import('appium/types').Args} Args
311
330
  * @typedef {import('./schema/arg-spec').ArgSpec} ArgSpec
312
331
  */
313
-
package/lib/constants.js CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  import path from 'path';
3
2
 
4
3
  /**
@@ -30,7 +29,7 @@ export const KNOWN_PLUGINS = Object.freeze(
30
29
  images: '@appium/images-plugin',
31
30
  'execute-driver': '@appium/execute-driver-plugin',
32
31
  'relaxed-caps': '@appium/relaxed-caps-plugin',
33
- }),
32
+ })
34
33
  );
35
34
 
36
35
  // This is a map of driver names to npm packages representing those drivers.
@@ -50,26 +49,18 @@ export const KNOWN_DRIVERS = Object.freeze(
50
49
  flutter: 'appium-flutter-driver',
51
50
  safari: 'appium-safari-driver',
52
51
  gecko: 'appium-geckodriver',
53
- }),
52
+ })
54
53
  );
55
54
 
56
55
  /**
57
56
  * Relative path to directory containing any Appium internal files
58
57
  */
59
- export const CACHE_DIR_RELATIVE_PATH = path.join(
60
- 'node_modules',
61
- '.cache',
62
- 'appium',
63
- );
58
+ export const CACHE_DIR_RELATIVE_PATH = path.join('node_modules', '.cache', 'appium');
64
59
 
65
60
  /**
66
61
  * Relative path to hashfile (from `APPIUM_HOME`) of consuming project's `package.json` (if it exists)
67
62
  */
68
- export const PKG_HASHFILE_RELATIVE_PATH = path.join(
69
- CACHE_DIR_RELATIVE_PATH,
70
- 'package.hash',
71
- );
72
-
63
+ export const PKG_HASHFILE_RELATIVE_PATH = path.join(CACHE_DIR_RELATIVE_PATH, 'package.hash');
73
64
 
74
65
  export const EXT_SUBCOMMAND_LIST = 'list';
75
66
  export const EXT_SUBCOMMAND_INSTALL = 'install';