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/utils.js CHANGED
@@ -1,65 +1,64 @@
1
+
1
2
  import _ from 'lodash';
2
3
  import logger from './logger';
3
- import { processCapabilities, PROTOCOLS } from 'appium-base-driver';
4
- import findRoot from 'find-root';
4
+ import { processCapabilities, PROTOCOLS } from '@appium/base-driver';
5
+ import { inspect as dump } from 'util';
5
6
 
6
7
  const W3C_APPIUM_PREFIX = 'appium';
7
8
 
8
- function inspectObject (args) {
9
- function getValueArray (obj, indent = ' ') {
10
- if (!_.isObject(obj)) {
11
- return [obj];
12
- }
9
+ /**
10
+ *
11
+ * If `stdout` is a TTY, this is `true`.
12
+ *
13
+ * Used for tighter control over log output.
14
+ * @type {boolean}
15
+ */
16
+ const isStdoutTTY = process.stdout.isTTY;
13
17
 
14
- let strArr = ['{'];
15
- for (let [arg, value] of _.toPairs(obj)) {
16
- if (!_.isObject(value)) {
17
- strArr.push(`${indent} ${arg}: ${value}`);
18
- } else {
19
- value = getValueArray(value, `${indent} `);
20
- strArr.push(`${indent} ${arg}: ${value.shift()}`);
21
- strArr.push(...value);
22
- }
23
- }
24
- strArr.push(`${indent}}`);
25
- return strArr;
26
- }
27
- for (let [arg, value] of _.toPairs(args)) {
28
- value = getValueArray(value);
29
- logger.info(` ${arg}: ${value.shift()}`);
30
- for (let val of value) {
31
- logger.info(val);
32
- }
33
- }
34
- }
18
+ /**
19
+ * Dumps to value to the console using `info` logger.
20
+ *
21
+ * @todo May want to force color to be `false` if {@link isStdoutTTY} is `false`.
22
+ */
23
+ const inspect = _.flow(
24
+ _.partialRight(
25
+ /** @type {(object: any, options: import('util').InspectOptions) => string} */(dump),
26
+ {colors: true, depth: null, compact: !isStdoutTTY}
27
+ ),
28
+ (...args) => {
29
+ logger.info(...args);
30
+ });
35
31
 
36
32
  /**
37
33
  * Takes the caps that were provided in the request and translates them
38
34
  * into caps that can be used by the inner drivers.
39
35
  *
40
- * @param {Object} jsonwpCapabilities
41
- * @param {Object} w3cCapabilities
42
- * @param {Object} constraints
43
- * @param {Object} defaultCapabilities
36
+ * @param {any} jsonwpCapabilities
37
+ * @param {W3CCapabilities} w3cCapabilities
38
+ * @param {import('@appium/types').Constraints} constraints
39
+ * @param {import('@appium/types').DefaultCapabilitiesConfig} [defaultCapabilities]
40
+ * @returns {ParsedDriverCaps|InvalidCaps}
44
41
  */
45
42
  function parseCapsForInnerDriver (jsonwpCapabilities, w3cCapabilities, constraints = {}, defaultCapabilities = {}) {
46
43
  // Check if the caller sent JSONWP caps, W3C caps, or both
47
44
  const hasW3CCaps = _.isPlainObject(w3cCapabilities) &&
48
45
  (_.has(w3cCapabilities, 'alwaysMatch') || _.has(w3cCapabilities, 'firstMatch'));
49
46
  const hasJSONWPCaps = _.isPlainObject(jsonwpCapabilities);
50
- let protocol = null;
51
- let desiredCaps = {};
52
- let processedW3CCapabilities = null;
53
- let processedJsonwpCapabilities = null;
54
-
55
- if (!hasJSONWPCaps && !hasW3CCaps) {
56
- return {
47
+ let desiredCaps = /** @type {ParsedDriverCaps['desiredCaps']} */({});
48
+ /** @type {ParsedDriverCaps['processedW3CCapabilities']} */
49
+ let processedW3CCapabilities;
50
+ /** @type {ParsedDriverCaps['processedJsonwpCapabilities']} */
51
+ let processedJsonwpCapabilities;
52
+
53
+ if (!hasW3CCaps) {
54
+ return /** @type {InvalidCaps} */({
57
55
  protocol: PROTOCOLS.W3C,
58
- error: new Error('Either JSONWP or W3C capabilities should be provided'),
59
- };
56
+ error: new Error('W3C capabilities should be provided'),
57
+ });
60
58
  }
61
59
 
62
- const {W3C, MJSONWP} = PROTOCOLS;
60
+ const {W3C} = PROTOCOLS;
61
+ const protocol = W3C;
63
62
 
64
63
  // Make sure we don't mutate the original arguments
65
64
  jsonwpCapabilities = _.cloneDeep(jsonwpCapabilities);
@@ -95,62 +94,30 @@ function parseCapsForInnerDriver (jsonwpCapabilities, w3cCapabilities, constrain
95
94
  }
96
95
  }
97
96
  if (hasJSONWPCaps) {
98
- jsonwpCapabilities = Object.assign({}, removeAppiumPrefixes(defaultCapabilities), jsonwpCapabilities);
97
+ jsonwpCapabilities = {...removeAppiumPrefixes(defaultCapabilities), ...jsonwpCapabilities};
99
98
  }
100
99
  }
101
100
 
102
101
  // Get MJSONWP caps
103
102
  if (hasJSONWPCaps) {
104
- protocol = MJSONWP;
105
- desiredCaps = jsonwpCapabilities;
106
103
  processedJsonwpCapabilities = {...jsonwpCapabilities};
107
104
  }
108
105
 
109
106
  // Get W3C caps
110
107
  if (hasW3CCaps) {
111
- protocol = W3C;
112
108
  // Call the process capabilities algorithm to find matching caps on the W3C
113
109
  // (see: https://github.com/jlipps/simple-wd-spec#processing-capabilities)
114
- let isFixingNeededForW3cCaps = false;
115
110
  try {
116
111
  desiredCaps = processCapabilities(w3cCapabilities, constraints, true);
117
112
  } catch (error) {
118
- if (!hasJSONWPCaps) {
119
- return {
120
- desiredCaps,
121
- processedJsonwpCapabilities,
122
- processedW3CCapabilities,
123
- protocol,
124
- error,
125
- };
126
- }
127
113
  logger.info(`Could not parse W3C capabilities: ${error.message}`);
128
- isFixingNeededForW3cCaps = true;
129
- }
130
-
131
- if (hasJSONWPCaps && !isFixingNeededForW3cCaps) {
132
- const differingKeys = _.difference(_.keys(removeAppiumPrefixes(processedJsonwpCapabilities)), _.keys(removeAppiumPrefixes(desiredCaps)));
133
- if (!_.isEmpty(differingKeys)) {
134
- logger.info(`The following capabilities were provided in the JSONWP desired capabilities that are missing ` +
135
- `in W3C capabilities: ${JSON.stringify(differingKeys)}`);
136
- isFixingNeededForW3cCaps = true;
137
- }
138
- }
139
-
140
- if (isFixingNeededForW3cCaps && hasJSONWPCaps) {
141
- logger.info('Trying to fix W3C capabilities by merging them with JSONWP caps');
142
- w3cCapabilities = fixW3cCapabilities(w3cCapabilities, jsonwpCapabilities);
143
- try {
144
- desiredCaps = processCapabilities(w3cCapabilities, constraints, true);
145
- } catch (error) {
146
- logger.warn(`Could not parse fixed W3C capabilities: ${error.message}. Falling back to JSONWP protocol`);
147
- return {
148
- desiredCaps: processedJsonwpCapabilities,
149
- processedJsonwpCapabilities,
150
- processedW3CCapabilities: null,
151
- protocol: MJSONWP,
152
- };
153
- }
114
+ return /** @type {InvalidCaps} */({
115
+ desiredCaps,
116
+ processedJsonwpCapabilities,
117
+ processedW3CCapabilities,
118
+ protocol,
119
+ error,
120
+ });
154
121
  }
155
122
 
156
123
  // Create a new w3c capabilities payload that contains only the matching caps in `alwaysMatch`
@@ -160,53 +127,13 @@ function parseCapsForInnerDriver (jsonwpCapabilities, w3cCapabilities, constrain
160
127
  };
161
128
  }
162
129
 
163
- return {desiredCaps, processedJsonwpCapabilities, processedW3CCapabilities, protocol};
164
- }
165
-
166
- /**
167
- * This helper method tries to fix corrupted W3C capabilities by
168
- * merging them to existing JSONWP capabilities.
169
- *
170
- * @param {Object} w3cCaps W3C capabilities
171
- * @param {Object} jsonwpCaps JSONWP capabilities
172
- * @return {Object} Fixed W3C capabilities
173
- */
174
- function fixW3cCapabilities (w3cCaps, jsonwpCaps) {
175
- const result = {
176
- firstMatch: w3cCaps.firstMatch || [],
177
- alwaysMatch: w3cCaps.alwaysMatch || {},
178
- };
179
- const keysToInsert = _.keys(jsonwpCaps);
180
- const removeMatchingKeys = (match) => {
181
- _.pull(keysToInsert, match);
182
- const colonIndex = match.indexOf(':');
183
- if (colonIndex >= 0 && match.length > colonIndex) {
184
- _.pull(keysToInsert, match.substring(colonIndex + 1));
185
- }
186
- if (keysToInsert.includes(`${W3C_APPIUM_PREFIX}:${match}`)) {
187
- _.pull(keysToInsert, `${W3C_APPIUM_PREFIX}:${match}`);
188
- }
189
- };
190
-
191
- for (const firstMatchEntry of result.firstMatch) {
192
- for (const pair of _.toPairs(firstMatchEntry)) {
193
- removeMatchingKeys(pair[0]);
194
- }
195
- }
196
-
197
- for (const pair of _.toPairs(result.alwaysMatch)) {
198
- removeMatchingKeys(pair[0]);
199
- }
200
-
201
- for (const key of keysToInsert) {
202
- result.alwaysMatch[key] = jsonwpCaps[key];
203
- }
204
- return result;
130
+ return /** @type {ParsedDriverCaps} */({desiredCaps, processedJsonwpCapabilities, processedW3CCapabilities, protocol});
205
131
  }
206
132
 
207
133
  /**
208
134
  * Takes a capabilities objects and prefixes capabilities with `appium:`
209
- * @param {Object} caps Desired capabilities object
135
+ * @param {Capabilities} caps Desired capabilities object
136
+ * @returns {AppiumW3CCapabilities}
210
137
  */
211
138
  function insertAppiumPrefixes (caps) {
212
139
  // Standard, non-prefixed capabilities (see https://www.w3.org/TR/webdriver/#dfn-table-of-standard-capabilities)
@@ -233,11 +160,17 @@ function insertAppiumPrefixes (caps) {
233
160
  return prefixedCaps;
234
161
  }
235
162
 
163
+ /**
164
+ *
165
+ * @param {AppiumW3CCapabilities} caps
166
+ * @returns {Capabilities}
167
+ */
236
168
  function removeAppiumPrefixes (caps) {
237
169
  if (!_.isPlainObject(caps)) {
238
170
  return caps;
239
171
  }
240
172
 
173
+ /** @type {Capabilities} */
241
174
  const fixedCaps = {};
242
175
  for (let [name, value] of _.toPairs(caps)) {
243
176
  fixedCaps[removeAppiumPrefix(name)] = value;
@@ -289,9 +222,32 @@ function pullSettings (caps) {
289
222
  return result;
290
223
  }
291
224
 
292
- const rootDir = findRoot(__dirname);
293
-
294
225
  export {
295
- inspectObject, parseCapsForInnerDriver, insertAppiumPrefixes, rootDir,
296
- getPackageVersion, pullSettings, removeAppiumPrefixes,
226
+ inspect, parseCapsForInnerDriver, insertAppiumPrefixes,
227
+ getPackageVersion, pullSettings, removeAppiumPrefixes
297
228
  };
229
+
230
+ /**
231
+ * @todo protocol is more specific
232
+ * @typedef ParsedDriverCaps
233
+ * @property {Capabilities} desiredCaps
234
+ * @property {string} protocol
235
+ * @property {any} [processedJsonwpCapabilities]
236
+ * @property {W3CCapabilities} [processedW3CCapabilities]
237
+ */
238
+
239
+ /**
240
+ * @todo protocol is more specific
241
+ * @typedef InvalidCaps
242
+ * @property {Error} error
243
+ * @property {string} protocol
244
+ * @property {Capabilities} [desiredCaps]
245
+ * @property {any} [processedJsonwpCapabilities]
246
+ * @property {W3CCapabilities} [processedW3CCapabilities]
247
+ */
248
+
249
+ /**
250
+ * @typedef {import('@appium/types').W3CCapabilities} W3CCapabilities
251
+ * @typedef {import('@appium/types').Capabilities} Capabilities
252
+ * @typedef {import('@appium/types').AppiumW3CCapabilities} AppiumW3CCapabilities
253
+ */
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "appium",
3
+ "version": "2.0.0-beta.30",
3
4
  "description": "Automation for Apps.",
4
- "tags": [
5
+ "keywords": [
5
6
  "automation",
6
7
  "javascript",
7
8
  "selenium",
@@ -11,102 +12,78 @@
11
12
  "firefoxos",
12
13
  "testing"
13
14
  ],
14
- "version": "2.0.0-beta.3",
15
- "author": "https://github.com/appium",
16
- "license": "Apache-2.0",
17
- "repository": {
18
- "type": "git",
19
- "url": "https://github.com/appium/appium.git"
20
- },
15
+ "homepage": "https://appium.io",
21
16
  "bugs": {
22
17
  "url": "https://github.com/appium/appium/issues"
23
18
  },
24
- "engines": {
25
- "node": ">=8",
26
- "npm": ">=6"
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/appium/appium.git",
22
+ "directory": "packages/appium"
27
23
  },
28
- "main": "./build/lib/main.js",
24
+ "license": "Apache-2.0",
25
+ "author": "https://github.com/appium",
29
26
  "bin": {
30
- "appium": "./build/lib/main.js"
27
+ "appium": "index.js"
31
28
  },
32
29
  "directories": {
33
- "lib": "./lib",
34
- "doc": "./docs"
30
+ "lib": "./lib"
35
31
  },
36
32
  "files": [
37
- "bin",
38
33
  "lib",
39
- "build/lib",
40
- "npm-shrinkwrap.json"
34
+ "build",
35
+ "index.js",
36
+ "scripts/postinstall.js",
37
+ "types"
41
38
  ],
39
+ "scripts": {
40
+ "build": "babel lib --root-mode=upward --out-dir=build/lib",
41
+ "dev": "npm run build -- --watch",
42
+ "fix": "npm run lint -- --fix",
43
+ "generate-docs": "node ./scripts/parse-yml-commands.js",
44
+ "postinstall": "node ./scripts/postinstall.js",
45
+ "lint": "eslint -c ../../.eslintrc --ignore-path ../../.eslintignore .",
46
+ "test": "npm run test:unit",
47
+ "test:e2e": "mocha --require ../../test/setup-babel.js --timeout 20s --slow 10s \"./test/e2e/**/*.spec.js\"",
48
+ "test:unit": "mocha --require ../../test/setup-babel.js \"./test/unit/**/*.spec.js\""
49
+ },
42
50
  "dependencies": {
43
- "@appium/base-plugin": "^1.0.0",
44
- "@babel/runtime": "^7.6.0",
45
- "appium-base-driver": "8.0.0-beta.0",
46
- "appium-support": "2.x",
47
- "argparse": "^1.0.10",
48
- "async-lock": "^1.0.0",
49
- "asyncbox": "2.x",
50
- "axios": "^0.20.0",
51
- "bluebird": "3.x",
52
- "continuation-local-storage": "3.x",
53
- "dateformat": "^3.0.3",
54
- "find-root": "^1.1.0",
55
- "lodash": "^4.17.11",
56
- "longjohn": "^0.2.12",
57
- "npmlog": "4.x",
58
- "ora": "^4.0.4",
59
- "semver": "^7.0.0",
60
- "source-map-support": "0.x",
61
- "teen_process": "1.x",
62
- "winston": "3.x",
63
- "word-wrap": "^1.2.3",
64
- "yaml": "^1.7.2"
51
+ "@appium/base-driver": "^8.4.2",
52
+ "@appium/base-plugin": "1.8.1",
53
+ "@appium/schema": "^0.0.2",
54
+ "@appium/support": "^2.57.1",
55
+ "@babel/runtime": "7.17.9",
56
+ "@sidvind/better-ajv-errors": "1.1.1",
57
+ "ajv": "8.11.0",
58
+ "ajv-formats": "2.1.1",
59
+ "argparse": "2.0.1",
60
+ "async-lock": "1.3.1",
61
+ "asyncbox": "2.9.2",
62
+ "axios": "0.26.1",
63
+ "bluebird": "3.7.2",
64
+ "find-up": "5.0.0",
65
+ "lilconfig": "2.0.5",
66
+ "lodash": "4.17.21",
67
+ "longjohn": "0.2.12",
68
+ "npmlog": "6.0.1",
69
+ "ora": "5.4.1",
70
+ "package-changed": "1.9.0",
71
+ "resolve-from": "5.0.0",
72
+ "semver": "7.3.6",
73
+ "source-map-support": "0.5.21",
74
+ "teen_process": "1.16.0",
75
+ "winston": "3.7.2",
76
+ "word-wrap": "1.2.3",
77
+ "yaml": "1.10.2"
65
78
  },
66
- "scripts": {
67
- "clean": "rm -rf node_modules && rm -f package-lock.json && npm install",
68
- "prepare": "gulp prepublish",
69
- "prepublishOnly": "npm run prune-shrinkwrap && gulp fixShrinkwrap",
70
- "postpublish": "npm run restore-shrinkwrap",
71
- "prune-shrinkwrap": "!(test -e npm-shrinkwrap.json) || (npm ci --production --ignore-scripts && npm run backup-shrinkwrap && npm shrinkwrap && npm install --only=dev --no-shrinkwrap)",
72
- "restore-shrinkwrap": "!(test -e npm-shrinkwrap.json) || (mv npm-shrinkwrap-backup.json npm-shrinkwrap.json)",
73
- "backup-shrinkwrap": "mv npm-shrinkwrap.json npm-shrinkwrap-backup.json",
74
- "check-pruned-shrinkwrap": "node check-pruned-shrinkwrap.js",
75
- "test": "gulp once",
76
- "e2e-test": "gulp e2e-test",
77
- "watch": "gulp watch",
78
- "build": "gulp transpile",
79
- "mocha": "mocha",
80
- "precommit-msg": "echo 'Pre-commit checks...' && exit 0",
81
- "precommit-test": "REPORTER=dot gulp once",
82
- "lint": "gulp lint",
83
- "lint:fix": "gulp lint --fix",
84
- "coverage": "gulp coveralls",
85
- "generate-docs": "node ./build/commands-yml/parse.js",
86
- "zip": "zip -qr appium.zip .",
87
- "upload": "gulp github-upload",
88
- "zip-and-upload": "npm run zip && npm run upload",
89
- "authorize-ios": "authorize-ios"
79
+ "engines": {
80
+ "node": ">=12",
81
+ "npm": ">=6"
90
82
  },
91
- "pre-commit": [
92
- "precommit-msg",
93
- "precommit-test"
94
- ],
95
- "devDependencies": {
96
- "@appium/fake-plugin": "^0.2.0",
97
- "appium-fake-driver": "^1.0.1",
98
- "appium-gulp-plugins": "^5.2.1",
99
- "chai": "4.x",
100
- "chai-as-promised": "7.x",
101
- "eslint-config-appium": "^4.0.1",
102
- "fancy-log": "^1.3.2",
103
- "gulp": "^4.0.0",
104
- "handlebars": "^4.2.0",
105
- "mocha": "^8.0.1",
106
- "pre-commit": "1.x",
107
- "sinon": "^9.0.0",
108
- "validate.js": "^0.13.0",
109
- "wd": "^1.10.0",
110
- "yaml-js": "^0.2.0"
111
- }
83
+ "publishConfig": {
84
+ "access": "public",
85
+ "tag": "next"
86
+ },
87
+ "types": "./build/lib/index.d.ts",
88
+ "gitHead": "319f7289e7019efaeac1271936b2d991041a02c2"
112
89
  }
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env node
2
+ /* eslint-disable no-console, promise/prefer-await-to-then */
3
+
4
+ async function main () {
5
+ const driverEnv = process.env.npm_config_drivers;
6
+ const pluginEnv = process.env.npm_config_plugins;
7
+
8
+ if (!driverEnv && !pluginEnv) {
9
+ console.log('Not auto-installing any drivers or plugins');
10
+ return;
11
+ }
12
+
13
+ let extension;
14
+ try {
15
+ extension = require('../build/lib/cli/extension');
16
+ } catch (e) {
17
+ throw new Error(`Could not load extension CLI file; has the project been transpiled? ` +
18
+ `(${e.message})`);
19
+ }
20
+
21
+ const {DEFAULT_APPIUM_HOME, DRIVER_TYPE, PLUGIN_TYPE} = require('./build/lib/extension-config');
22
+ const {runExtensionCommand} = extension;
23
+ const appiumHome = process.env.npm_config_appium_home || DEFAULT_APPIUM_HOME;
24
+ const specs = [[DRIVER_TYPE, driverEnv], [PLUGIN_TYPE, pluginEnv]];
25
+
26
+ for (const [type, extEnv] of specs) {
27
+ if (extEnv) {
28
+ for (const ext of extEnv.split(',')) {
29
+ try {
30
+ await checkAndInstallExtension({runExtensionCommand, appiumHome, type, ext});
31
+ } catch (e) {
32
+ console.log(`There was an error checking and installing ${type} ${ext}: ${e.message}`);
33
+ }
34
+ }
35
+ }
36
+ }
37
+ }
38
+
39
+ async function checkAndInstallExtension ({
40
+ runExtensionCommand,
41
+ appiumHome,
42
+ type,
43
+ ext,
44
+ }) {
45
+ const extList = await runExtensionCommand({
46
+ appiumHome,
47
+ [`${type}Command`]: 'list',
48
+ showInstalled: true,
49
+ suppressOutput: true,
50
+ }, type);
51
+ if (extList[ext]) {
52
+ console.log(`The ${type} ${ext} was already installed, skipping...`);
53
+ return;
54
+ }
55
+ console.log(`Installing the ${type} ${ext}...`);
56
+ await runExtensionCommand({
57
+ appiumHome,
58
+ [`${type}Command`]: 'install',
59
+ [type]: ext,
60
+ suppressOutput: true,
61
+ }, type);
62
+ }
63
+
64
+ if (require.main === module) {
65
+ main().then(() => {
66
+ process.exit(0);
67
+ }).catch((e) => {
68
+ console.error(e);
69
+ process.exit(1);
70
+ });
71
+ }
@@ -0,0 +1,61 @@
1
+ import { CommonMetadata, ExtMetadata, SchemaMetadata } from './external-manifest';
2
+ import { ExtensionType, DriverType, PluginType } from '.';
3
+
4
+ export type InstallType = 'npm' | 'git' | 'local' | 'github';
5
+
6
+ export interface InternalMetadata {
7
+ pkgName: string;
8
+ version: string;
9
+ installType: InstallType;
10
+ /**
11
+ * Whatever the user typed as the extension to install. May be derived from `package.json`
12
+ */
13
+ installSpec: string;
14
+ }
15
+
16
+ /**
17
+ * Combination of external + internal extension data with `driverName`/`pluginName` removed (it becomes a key in an {@linkcode ExtRecord} object).
18
+ * Part of `extensions.yaml`.
19
+ */
20
+ export type ExtManifest<ExtType extends ExtensionType> = Omit<
21
+ ExtMetadata<ExtType>,
22
+ ExtType extends DriverType
23
+ ? 'driverName'
24
+ : ExtType extends PluginType
25
+ ? 'pluginName'
26
+ : never
27
+ > &
28
+ InternalMetadata &
29
+ CommonMetadata; // XXX: ExtMetadata should be a union with CommonMetadata. why is this needed?
30
+
31
+ type WithSchemaManifest = {
32
+ schema: SchemaMetadata;
33
+ };
34
+
35
+ /**
36
+ * This is just a {@linkcode ExtManifest} except it _for sure_ has a `schema` prop.
37
+ */
38
+ export type ExtManifestWithSchema<ExtType extends ExtensionType> =
39
+ ExtManifest<ExtType> & WithSchemaManifest;
40
+
41
+ /**
42
+ * Generic type for an object keyed by extension name, with values of type {@linkcode ExtData}
43
+ */
44
+ export type ExtRecord<ExtType extends ExtensionType> = Record<
45
+ string,
46
+ ExtManifest<ExtType>
47
+ >;
48
+
49
+ export type DriverRecord = ExtRecord<DriverType>;
50
+ export type PluginRecord = ExtRecord<PluginType>;
51
+
52
+ export type ExtName<ExtType extends ExtensionType> = keyof ExtRecord<ExtType>;
53
+
54
+ /**
55
+ * Represents an entire YAML manifest (`extensions.yaml`)
56
+ */
57
+ export interface ManifestData {
58
+ drivers: DriverRecord;
59
+ plugins: PluginRecord;
60
+ schemaRev?: number;
61
+ }