appium 2.0.0-beta.17 → 2.0.0-beta.20

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 (53) hide show
  1. package/build/lib/appium-config.schema.json +0 -0
  2. package/build/lib/appium.js +84 -69
  3. package/build/lib/cli/argparse-actions.js +1 -1
  4. package/build/lib/cli/args.js +87 -223
  5. package/build/lib/cli/extension-command.js +2 -2
  6. package/build/lib/cli/extension.js +14 -6
  7. package/build/lib/cli/parser.js +142 -106
  8. package/build/lib/cli/utils.js +1 -1
  9. package/build/lib/config-file.js +141 -0
  10. package/build/lib/config.js +42 -64
  11. package/build/lib/driver-config.js +41 -20
  12. package/build/lib/drivers.js +1 -1
  13. package/build/lib/ext-config-io.js +165 -0
  14. package/build/lib/extension-config.js +110 -60
  15. package/build/lib/grid-register.js +19 -21
  16. package/build/lib/logsink.js +1 -1
  17. package/build/lib/main.js +135 -72
  18. package/build/lib/plugin-config.js +17 -8
  19. package/build/lib/schema/appium-config-schema.js +252 -0
  20. package/build/lib/schema/arg-spec.js +120 -0
  21. package/build/lib/schema/cli-args.js +173 -0
  22. package/build/lib/schema/cli-transformers.js +76 -0
  23. package/build/lib/schema/index.js +36 -0
  24. package/build/lib/schema/keywords.js +62 -0
  25. package/build/lib/schema/schema.js +357 -0
  26. package/build/lib/utils.js +26 -35
  27. package/lib/appium-config.schema.json +277 -0
  28. package/lib/appium.js +99 -75
  29. package/lib/cli/args.js +138 -335
  30. package/lib/cli/extension-command.js +7 -6
  31. package/lib/cli/extension.js +12 -4
  32. package/lib/cli/parser.js +248 -96
  33. package/lib/config-file.js +227 -0
  34. package/lib/config.js +71 -61
  35. package/lib/driver-config.js +66 -11
  36. package/lib/ext-config-io.js +287 -0
  37. package/lib/extension-config.js +209 -66
  38. package/lib/grid-register.js +24 -21
  39. package/lib/main.js +139 -68
  40. package/lib/plugin-config.js +32 -2
  41. package/lib/schema/appium-config-schema.js +286 -0
  42. package/lib/schema/arg-spec.js +218 -0
  43. package/lib/schema/cli-args.js +273 -0
  44. package/lib/schema/cli-transformers.js +123 -0
  45. package/lib/schema/index.js +2 -0
  46. package/lib/schema/keywords.js +119 -0
  47. package/lib/schema/schema.js +577 -0
  48. package/lib/utils.js +29 -52
  49. package/package.json +16 -11
  50. package/types/appium-config.d.ts +197 -0
  51. package/types/types.d.ts +201 -0
  52. package/build/lib/cli/parser-helpers.js +0 -106
  53. package/lib/cli/parser-helpers.js +0 -106
@@ -1,106 +0,0 @@
1
- import fs from 'fs';
2
- import _ from 'lodash';
3
- import { INSTALL_TYPES } from '../extension-config';
4
-
5
- // serverArgs will be added to the `server` (default) subcommand
6
- function parseSecurityFeatures (features) {
7
- const splitter = (splitOn, str) => `${str}`.split(splitOn)
8
- .map((s) => s.trim())
9
- .filter(Boolean);
10
- let parsedFeatures;
11
- try {
12
- parsedFeatures = splitter(',', features);
13
- } catch (err) {
14
- throw new TypeError('Could not parse value of --allow/deny-insecure. Should be ' +
15
- 'a list of strings separated by commas, or a path to a file ' +
16
- 'listing one feature name per line.');
17
- }
18
-
19
- if (parsedFeatures.length === 1 && fs.existsSync(parsedFeatures[0])) {
20
- // we might have a file which is a list of features
21
- try {
22
- const fileFeatures = fs.readFileSync(parsedFeatures[0], 'utf8');
23
- parsedFeatures = splitter('\n', fileFeatures);
24
- } catch (err) {
25
- throw new TypeError(`Attempted to read --allow/deny-insecure feature names ` +
26
- `from file ${parsedFeatures[0]} but got error: ${err.message}`);
27
- }
28
- }
29
-
30
- return parsedFeatures;
31
- }
32
-
33
- function parseDriverNames (names) {
34
- if (!_.isString(names)) {
35
- throw new TypeError('To parse driver names, names must be a CSV string');
36
- }
37
-
38
- try {
39
- return names.split(',').map((s) => s.trim()).filter(Boolean);
40
- } catch (err) {
41
- throw new TypeError('Could not parse value of --drivers. Should be a list of driver names ' +
42
- 'separated by commas. Driver names are those found when running `appium ' +
43
- 'driver list`');
44
- }
45
- }
46
-
47
- function parsePluginNames (names) {
48
- if (!_.isString(names)) {
49
- throw new TypeError('To parse plugin names, names must be a CSV string');
50
- }
51
-
52
- try {
53
- return names.split(',').map((s) => s.trim()).filter(Boolean);
54
- } catch (err) {
55
- throw new TypeError('Could not parse value of --plugins. Should be a list of plugin names ' +
56
- 'separated by commas. Plugin names are those found when running `appium ' +
57
- 'plugin list`');
58
- }
59
- }
60
-
61
- function parseJsonStringOrFile (capsOrPath) {
62
- let caps = capsOrPath;
63
- let loadedFromFile = false;
64
- try {
65
- // use synchronous file access, as `argparse` provides no way of either
66
- // awaiting or using callbacks. This step happens in startup, in what is
67
- // effectively command-line code, so nothing is blocked in terms of
68
- // sessions, so holding up the event loop does not incur the usual
69
- // drawbacks.
70
- if (_.isString(capsOrPath) && fs.statSync(capsOrPath).isFile()) {
71
- caps = fs.readFileSync(capsOrPath, 'utf8');
72
- loadedFromFile = true;
73
- }
74
- } catch (err) {
75
- // not a file, or not readable
76
- }
77
- try {
78
- const result = JSON.parse(caps);
79
- if (!_.isPlainObject(result)) {
80
- throw new Error(`'${_.truncate(result, {length: 100})}' is not an object`);
81
- }
82
- return result;
83
- } catch (e) {
84
- const msg = loadedFromFile
85
- ? `The provided value of '${capsOrPath}' must be a valid JSON`
86
- : `The provided value must be a valid JSON`;
87
- throw new TypeError(`${msg}. Original error: ${e.message}`);
88
- }
89
- }
90
-
91
- function parseInstallTypes (source) {
92
- if (!_.includes(INSTALL_TYPES, source)) {
93
- throw `Argument to --source was '${source}', which is not a valid ` +
94
- `driver source type. It must be one of ${JSON.stringify(INSTALL_TYPES)}`;
95
- }
96
-
97
- return source;
98
- }
99
-
100
- export {
101
- parseSecurityFeatures,
102
- parseJsonStringOrFile,
103
- parseInstallTypes,
104
- parsePluginNames,
105
- parseDriverNames,
106
- };