appium 2.0.0-beta.33 → 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 (124) 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 +5 -5
  8. package/build/lib/cli/driver-command.d.ts.map +1 -1
  9. package/build/lib/cli/driver-command.js +8 -8
  10. package/build/lib/cli/extension-command.d.ts +78 -51
  11. package/build/lib/cli/extension-command.d.ts.map +1 -1
  12. package/build/lib/cli/extension-command.js +135 -80
  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 +9 -15
  20. package/build/lib/cli/plugin-command.d.ts.map +1 -1
  21. package/build/lib/cli/plugin-command.js +8 -8
  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/index.js +1 -1
  65. package/build/lib/schema/keywords.d.ts.map +1 -1
  66. package/build/lib/schema/keywords.js +1 -1
  67. package/build/lib/schema/schema.d.ts +2 -2
  68. package/build/lib/schema/schema.d.ts.map +1 -1
  69. package/build/lib/schema/schema.js +1 -1
  70. package/build/lib/utils.d.ts.map +1 -1
  71. package/build/lib/utils.js +1 -1
  72. package/build/tsconfig.tsbuildinfo +1 -1
  73. package/build/types/appium-manifest.d.ts +23 -4
  74. package/build/types/appium-manifest.d.ts.map +1 -1
  75. package/build/types/cli.d.ts.map +1 -1
  76. package/build/types/{external-manifest.d.ts → extension-manifest.d.ts} +15 -7
  77. package/build/types/extension-manifest.d.ts.map +1 -0
  78. package/build/types/index.d.ts +6 -5
  79. package/build/types/index.d.ts.map +1 -1
  80. package/driver.d.ts +1 -0
  81. package/driver.js +14 -0
  82. package/lib/appium.js +208 -124
  83. package/lib/cli/args.js +143 -93
  84. package/lib/cli/driver-command.js +46 -26
  85. package/lib/cli/extension-command.js +314 -157
  86. package/lib/cli/extension.js +15 -19
  87. package/lib/cli/parser.js +19 -31
  88. package/lib/cli/plugin-command.js +39 -24
  89. package/lib/cli/utils.js +8 -14
  90. package/lib/config-file.js +21 -25
  91. package/lib/config.js +82 -64
  92. package/lib/constants.js +4 -13
  93. package/lib/extension/driver-config.js +171 -171
  94. package/lib/extension/extension-config.js +347 -126
  95. package/lib/extension/index.js +72 -58
  96. package/lib/extension/manifest.js +48 -57
  97. package/lib/extension/package-changed.js +9 -8
  98. package/lib/extension/plugin-config.js +62 -62
  99. package/lib/grid-register.js +29 -18
  100. package/lib/logger.js +1 -2
  101. package/lib/logsink.js +29 -31
  102. package/lib/main.js +111 -73
  103. package/lib/schema/arg-spec.js +10 -13
  104. package/lib/schema/cli-args.js +14 -37
  105. package/lib/schema/cli-transformers.js +7 -14
  106. package/lib/schema/keywords.js +15 -13
  107. package/lib/schema/schema.js +58 -75
  108. package/lib/utils.js +50 -25
  109. package/package.json +27 -20
  110. package/plugin.d.ts +1 -0
  111. package/plugin.js +13 -0
  112. package/scripts/autoinstall-extensions.js +177 -0
  113. package/support.d.ts +1 -0
  114. package/support.js +13 -0
  115. package/types/appium-manifest.ts +27 -15
  116. package/types/cli.ts +2 -9
  117. package/types/{external-manifest.ts → extension-manifest.ts} +21 -15
  118. package/types/index.ts +12 -5
  119. package/build/types/extension.d.ts +0 -43
  120. package/build/types/extension.d.ts.map +0 -1
  121. package/build/types/external-manifest.d.ts.map +0 -1
  122. package/lib/appium-config.schema.json +0 -278
  123. package/scripts/postinstall.js +0 -71
  124. package/types/extension.ts +0 -56
package/lib/cli/args.js CHANGED
@@ -1,9 +1,16 @@
1
-
2
1
  // @ts-ignore
3
2
  import _ from 'lodash';
4
- import { DRIVER_TYPE, PLUGIN_TYPE, EXT_SUBCOMMAND_INSTALL, EXT_SUBCOMMAND_LIST, EXT_SUBCOMMAND_RUN, EXT_SUBCOMMAND_UNINSTALL, EXT_SUBCOMMAND_UPDATE } from '../constants';
5
- import { INSTALL_TYPES } from '../extension/extension-config';
6
- import { toParserArgs } from '../schema/cli-args';
3
+ import {
4
+ DRIVER_TYPE,
5
+ PLUGIN_TYPE,
6
+ EXT_SUBCOMMAND_INSTALL,
7
+ EXT_SUBCOMMAND_LIST,
8
+ EXT_SUBCOMMAND_RUN,
9
+ EXT_SUBCOMMAND_UNINSTALL,
10
+ EXT_SUBCOMMAND_UPDATE,
11
+ } from '../constants';
12
+ import {INSTALL_TYPES} from '../extension/extension-config';
13
+ import {toParserArgs} from '../schema/cli-args';
7
14
  const DRIVER_EXAMPLE = 'xcuitest';
8
15
  const PLUGIN_EXAMPLE = 'find_by_image';
9
16
 
@@ -19,19 +26,22 @@ const EXTENSION_TYPES = new Set([DRIVER_TYPE, PLUGIN_TYPE]);
19
26
  // this set of args works for both drivers and plugins ('extensions')
20
27
  /** @type {ArgumentDefinitions} */
21
28
  const globalExtensionArgs = new Map([
22
- [['--json'], {
23
- required: false,
24
- default: false,
25
- action: 'store_true',
26
- help: 'Use JSON for output format',
27
- dest: 'json'
28
- }]
29
+ [
30
+ ['--json'],
31
+ {
32
+ required: false,
33
+ default: false,
34
+ action: 'store_true',
35
+ help: 'Use JSON for output format',
36
+ dest: 'json',
37
+ },
38
+ ],
29
39
  ]);
30
40
 
31
41
  /**
32
42
  * Builds a Record of extension types to a Record of subcommands to their argument definitions
33
43
  */
34
- const getExtensionArgs = _.memoize(function getExtensionArgs () {
44
+ const getExtensionArgs = _.memoize(function getExtensionArgs() {
35
45
  const extensionArgs = {};
36
46
  for (const type of EXTENSION_TYPES) {
37
47
  extensionArgs[type] = {
@@ -42,7 +52,9 @@ const getExtensionArgs = _.memoize(function getExtensionArgs () {
42
52
  [EXT_SUBCOMMAND_RUN]: makeRunArgs(type),
43
53
  };
44
54
  }
45
- return /** @type {Record<ExtensionType, Record<import('../../types/cli').CliExtensionSubcommand,ArgumentDefinitions>>} */(extensionArgs);
55
+ return /** @type {Record<ExtensionType, Record<import('appium/types').CliExtensionSubcommand,ArgumentDefinitions>>} */ (
56
+ extensionArgs
57
+ );
46
58
  });
47
59
 
48
60
  /**
@@ -50,23 +62,29 @@ const getExtensionArgs = _.memoize(function getExtensionArgs () {
50
62
  * @param {ExtensionType} type
51
63
  * @returns {ArgumentDefinitions}
52
64
  */
53
- function makeListArgs (type) {
65
+ function makeListArgs(type) {
54
66
  return new Map([
55
67
  ...globalExtensionArgs,
56
- [['--installed'], {
57
- required: false,
58
- default: false,
59
- action: 'store_true',
60
- help: `List only installed ${type}s`,
61
- dest: 'showInstalled'
62
- }],
63
- [['--updates'], {
64
- required: false,
65
- default: false,
66
- action: 'store_true',
67
- help: 'Show information about newer versions',
68
- dest: 'showUpdates'
69
- }]
68
+ [
69
+ ['--installed'],
70
+ {
71
+ required: false,
72
+ default: false,
73
+ action: 'store_true',
74
+ help: `List only installed ${type}s`,
75
+ dest: 'showInstalled',
76
+ },
77
+ ],
78
+ [
79
+ ['--updates'],
80
+ {
81
+ required: false,
82
+ default: false,
83
+ action: 'store_true',
84
+ help: 'Show information about newer versions',
85
+ dest: 'showUpdates',
86
+ },
87
+ ],
70
88
  ]);
71
89
  }
72
90
 
@@ -75,48 +93,65 @@ function makeListArgs (type) {
75
93
  * @param {ExtensionType} type
76
94
  * @returns {ArgumentDefinitions}
77
95
  */
78
- function makeInstallArgs (type) {
96
+ function makeInstallArgs(type) {
79
97
  return new Map([
80
98
  ...globalExtensionArgs,
81
- [[type], {
82
- type: 'str',
83
- help: `Name of the ${type} to install, for example: ` +
84
- type === DRIVER_TYPE ? DRIVER_EXAMPLE : PLUGIN_EXAMPLE,
85
- }],
86
- [['--source'], {
87
- required: false,
88
- default: null,
89
- choices: INSTALL_TYPES_ARRAY,
90
- help: `Where to look for the ${type} if it is not one of Appium's verified ` +
91
- `${type}s. Possible values: ${INSTALL_TYPES_ARRAY.join(', ')}`,
92
- dest: 'installType'
93
- }],
94
- [['--package'], {
95
- required: false,
96
- default: null,
97
- type: 'str',
98
- help: `If installing from Git or GitHub, the package name, as defined in the plugin's ` +
99
- `package.json file in the "name" field, cannot be determined automatically, and ` +
100
- `should be reported here, otherwise the install will probably fail.`,
101
- dest: 'packageName',
102
- }],
99
+ [
100
+ [type],
101
+ {
102
+ type: 'str',
103
+ help:
104
+ `Name of the ${type} to install, for example: ` + type === DRIVER_TYPE
105
+ ? DRIVER_EXAMPLE
106
+ : PLUGIN_EXAMPLE,
107
+ },
108
+ ],
109
+ [
110
+ ['--source'],
111
+ {
112
+ required: false,
113
+ default: null,
114
+ choices: INSTALL_TYPES_ARRAY,
115
+ help:
116
+ `Where to look for the ${type} if it is not one of Appium's verified ` +
117
+ `${type}s. Possible values: ${INSTALL_TYPES_ARRAY.join(', ')}`,
118
+ dest: 'installType',
119
+ },
120
+ ],
121
+ [
122
+ ['--package'],
123
+ {
124
+ required: false,
125
+ default: null,
126
+ type: 'str',
127
+ help:
128
+ `If installing from Git or GitHub, the package name, as defined in the plugin's ` +
129
+ `package.json file in the "name" field, cannot be determined automatically, and ` +
130
+ `should be reported here, otherwise the install will probably fail.`,
131
+ dest: 'packageName',
132
+ },
133
+ ],
103
134
  ]);
104
135
  }
105
136
 
106
-
107
137
  /**
108
138
  * Makes the opts for the `uninstall` subcommand for each extension type
109
139
  * @param {ExtensionType} type
110
140
  * @returns {ArgumentDefinitions}
111
141
  */
112
- function makeUninstallArgs (type) {
142
+ function makeUninstallArgs(type) {
113
143
  return new Map([
114
144
  ...globalExtensionArgs,
115
- [[type], {
116
- type: 'str',
117
- help: 'Name of the driver to uninstall, for example: ' +
118
- type === DRIVER_TYPE ? DRIVER_EXAMPLE : PLUGIN_EXAMPLE
119
- }],
145
+ [
146
+ [type],
147
+ {
148
+ type: 'str',
149
+ help:
150
+ 'Name of the driver to uninstall, for example: ' + type === DRIVER_TYPE
151
+ ? DRIVER_EXAMPLE
152
+ : PLUGIN_EXAMPLE,
153
+ },
154
+ ],
120
155
  ]);
121
156
  }
122
157
 
@@ -125,22 +160,34 @@ function makeUninstallArgs (type) {
125
160
  * @param {ExtensionType} type
126
161
  * @returns {ArgumentDefinitions}
127
162
  */
128
- function makeUpdateArgs (type) {
163
+ function makeUpdateArgs(type) {
129
164
  return new Map([
130
165
  ...globalExtensionArgs,
131
- [[type], {
132
- type: 'str',
133
- help: `Name of the ${type} to update, or the word "installed" to update all installed ` +
166
+ [
167
+ [type],
168
+ {
169
+ type: 'str',
170
+ help:
171
+ `Name of the ${type} to update, or the word "installed" to update all installed ` +
134
172
  `${type}s. To see available updates, run "appium ${type} list --installed --updates". ` +
135
- 'For example: ' + type === DRIVER_TYPE ? DRIVER_EXAMPLE : PLUGIN_EXAMPLE,
136
- }],
137
- [['--unsafe'], {
138
- required: false,
139
- default: false,
140
- action: 'store_true',
141
- help: `Include updates that might have a new major revision, and potentially include ` +
142
- `breaking changes`,
143
- }],
173
+ 'For example: ' +
174
+ type ===
175
+ DRIVER_TYPE
176
+ ? DRIVER_EXAMPLE
177
+ : PLUGIN_EXAMPLE,
178
+ },
179
+ ],
180
+ [
181
+ ['--unsafe'],
182
+ {
183
+ required: false,
184
+ default: false,
185
+ action: 'store_true',
186
+ help:
187
+ `Include updates that might have a new major revision, and potentially include ` +
188
+ `breaking changes`,
189
+ },
190
+ ],
144
191
  ]);
145
192
  }
146
193
 
@@ -149,20 +196,29 @@ function makeUpdateArgs (type) {
149
196
  * @param {ExtensionType} type
150
197
  * @returns {ArgumentDefinitions}
151
198
  */
152
- function makeRunArgs (type) {
199
+ function makeRunArgs(type) {
153
200
  return new Map([
154
201
  ...globalExtensionArgs,
155
- [[type], {
156
- type: 'str',
157
- help: `Name of the ${type} to run a script from, for example: ` +
158
- type === DRIVER_TYPE ? DRIVER_EXAMPLE : PLUGIN_EXAMPLE,
159
- }],
160
- [['scriptName'], {
161
- default: null,
162
- type: 'str',
163
- help: `Name of the script to run from the ${type}. The script name must be cached ` +
164
- `inside the "scripts" field under "appium" inside the ${type}'s "package.json" file`
165
- }],
202
+ [
203
+ [type],
204
+ {
205
+ type: 'str',
206
+ help:
207
+ `Name of the ${type} to run a script from, for example: ` + type === DRIVER_TYPE
208
+ ? DRIVER_EXAMPLE
209
+ : PLUGIN_EXAMPLE,
210
+ },
211
+ ],
212
+ [
213
+ ['scriptName'],
214
+ {
215
+ default: null,
216
+ type: 'str',
217
+ help:
218
+ `Name of the script to run from the ${type}. The script name must be cached ` +
219
+ `inside the "scripts" field under "appium" inside the ${type}'s "package.json" file`,
220
+ },
221
+ ],
166
222
  ]);
167
223
  }
168
224
 
@@ -171,11 +227,8 @@ function makeRunArgs (type) {
171
227
  * which are disallowed in the config file.
172
228
  * @returns {ArgumentDefinitions}
173
229
  */
174
- function getServerArgs () {
175
- return new Map([
176
- ...toParserArgs(),
177
- ...serverArgsDisallowedInConfig,
178
- ]);
230
+ function getServerArgs() {
231
+ return new Map([...toParserArgs(), ...serverArgsDisallowedInConfig]);
179
232
  }
180
233
 
181
234
  /**
@@ -211,7 +264,7 @@ const serverArgsDisallowedInConfig = new Map([
211
264
  const: true,
212
265
  required: false,
213
266
  help: 'Show the current Appium configuration and exit',
214
- }
267
+ },
215
268
  ],
216
269
  [
217
270
  ['--config'],
@@ -224,10 +277,7 @@ const serverArgsDisallowedInConfig = new Map([
224
277
  ],
225
278
  ]);
226
279
 
227
- export {
228
- getServerArgs,
229
- getExtensionArgs
230
- };
280
+ export {getServerArgs, getExtensionArgs};
231
281
 
232
282
  /**
233
283
  * Alias
@@ -1,60 +1,80 @@
1
1
  import _ from 'lodash';
2
2
  import ExtensionCommand from './extension-command';
3
- import { KNOWN_DRIVERS } from '../constants';
3
+ import {KNOWN_DRIVERS} from '../constants';
4
4
  import '@colors/colors';
5
5
 
6
6
  const REQ_DRIVER_FIELDS = ['driverName', 'automationName', 'platformNames', 'mainClass'];
7
+
7
8
  /**
8
- * @extends {ExtensionCommand<import('../extension/manifest').DriverType>}
9
+ * @extends {ExtensionCommand<DriverType>}
9
10
  */
10
11
  export default class DriverCommand extends ExtensionCommand {
11
-
12
12
  /**
13
- * @param {DriverCommandOptions} opts
13
+ * @param {import('./extension-command').ExtensionCommandOptions<DriverType>} opts
14
14
  */
15
- constructor ({config, json}) {
15
+ constructor({config, json}) {
16
16
  super({config, json});
17
17
  this.knownExtensions = KNOWN_DRIVERS;
18
18
  }
19
19
 
20
- async install ({driver, installType, packageName}) {
21
- return await super._install({ext: driver, installType, packageName});
20
+ async install({driver, installType, packageName}) {
21
+ return await super._install({
22
+ installSpec: driver,
23
+ installType,
24
+ packageName,
25
+ });
22
26
  }
23
27
 
24
- async uninstall ({driver}) {
25
- return await super._uninstall({ext: driver});
28
+ async uninstall({driver}) {
29
+ return await super._uninstall({installSpec: driver});
26
30
  }
27
31
 
28
- async update ({driver, unsafe}) {
29
- return await super._update({ext: driver, unsafe});
32
+ async update({driver, unsafe}) {
33
+ return await super._update({installSpec: driver, unsafe});
30
34
  }
31
35
 
32
- async run ({driver, scriptName}) {
33
- return await super._run({ext: driver, scriptName});
36
+ async run({driver, scriptName}) {
37
+ return await super._run({installSpec: driver, scriptName});
34
38
  }
35
39
 
36
- getPostInstallText ({extName, extData}) {
37
- return `Driver ${extName}@${extData.version} successfully installed\n`.green +
38
- `- automationName: ${extData.automationName.green}\n` +
39
- `- platformNames: ${JSON.stringify(extData.platformNames).green}`;
40
+ getPostInstallText({extName, extData}) {
41
+ return (
42
+ `Driver ${extName}@${extData.version} successfully installed\n`.green +
43
+ `- automationName: ${extData.automationName.green}\n` +
44
+ `- platformNames: ${JSON.stringify(extData.platformNames).green}`
45
+ );
40
46
  }
41
47
 
42
- validateExtensionFields (appiumPkgData) {
43
- const missingFields = REQ_DRIVER_FIELDS.reduce((acc, field) => (
44
- appiumPkgData[field] ? acc : [...acc, field]
45
- ), []);
48
+ /**
49
+ * Validates fields in `appium` field of `driverMetadata`
50
+ *
51
+ * For any `package.json` fields which a driver requires, validate the type of
52
+ * those fields on the `package.json` data, throwing an error if anything is
53
+ * amiss.
54
+ * @param {import('appium/types').ExtMetadata<DriverType>} driverMetadata
55
+ * @param {string} installSpec
56
+ */
57
+ validateExtensionFields(driverMetadata, installSpec) {
58
+ const missingFields = REQ_DRIVER_FIELDS.reduce(
59
+ (acc, field) => (driverMetadata[field] ? acc : [...acc, field]),
60
+ []
61
+ );
46
62
 
47
63
  if (!_.isEmpty(missingFields)) {
48
- throw new Error(`Installed driver did not expose correct fields for compability ` +
49
- `with Appium. Missing fields: ${JSON.stringify(missingFields)}`);
64
+ throw new Error(
65
+ `Driver "${installSpec}" did not expose correct fields for compability ` +
66
+ `with Appium. Missing fields: ${JSON.stringify(missingFields)}`
67
+ );
50
68
  }
51
-
52
69
  }
53
-
54
70
  }
55
71
 
56
72
  /**
57
73
  * @typedef DriverCommandOptions
58
- * @property {import('../extension/extension-config').ExtensionConfig<import('../extension/manifest').DriverType>} config
74
+ * @property {import('../extension/extension-config').ExtensionConfig<DriverType>} config
59
75
  * @property {boolean} json
60
76
  */
77
+
78
+ /**
79
+ * @typedef {import('@appium/types').DriverType} DriverType
80
+ */