appium 2.0.0-beta.5 → 2.0.0-beta.53

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 (199) hide show
  1. package/README.md +156 -63
  2. package/build/lib/appium.d.ts +226 -0
  3. package/build/lib/appium.d.ts.map +1 -0
  4. package/build/lib/appium.js +694 -439
  5. package/build/lib/appium.js.map +1 -0
  6. package/build/lib/cli/args.d.ts +17 -0
  7. package/build/lib/cli/args.d.ts.map +1 -0
  8. package/build/lib/cli/args.js +253 -319
  9. package/build/lib/cli/args.js.map +1 -0
  10. package/build/lib/cli/driver-command.d.ts +102 -0
  11. package/build/lib/cli/driver-command.d.ts.map +1 -0
  12. package/build/lib/cli/driver-command.js +126 -81
  13. package/build/lib/cli/driver-command.js.map +1 -0
  14. package/build/lib/cli/extension-command.d.ts +385 -0
  15. package/build/lib/cli/extension-command.d.ts.map +1 -0
  16. package/build/lib/cli/extension-command.js +731 -383
  17. package/build/lib/cli/extension-command.js.map +1 -0
  18. package/build/lib/cli/extension.d.ts +23 -0
  19. package/build/lib/cli/extension.d.ts.map +1 -0
  20. package/build/lib/cli/extension.js +71 -54
  21. package/build/lib/cli/extension.js.map +1 -0
  22. package/build/lib/cli/parser.d.ts +84 -0
  23. package/build/lib/cli/parser.d.ts.map +1 -0
  24. package/build/lib/cli/parser.js +240 -128
  25. package/build/lib/cli/parser.js.map +1 -0
  26. package/build/lib/cli/plugin-command.d.ts +99 -0
  27. package/build/lib/cli/plugin-command.d.ts.map +1 -0
  28. package/build/lib/cli/plugin-command.js +120 -81
  29. package/build/lib/cli/plugin-command.js.map +1 -0
  30. package/build/lib/cli/utils.d.ts +29 -0
  31. package/build/lib/cli/utils.d.ts.map +1 -0
  32. package/build/lib/cli/utils.js +72 -51
  33. package/build/lib/cli/utils.js.map +1 -0
  34. package/build/lib/config-file.d.ts +100 -0
  35. package/build/lib/config-file.d.ts.map +1 -0
  36. package/build/lib/config-file.js +207 -0
  37. package/build/lib/config-file.js.map +1 -0
  38. package/build/lib/config.d.ts +49 -0
  39. package/build/lib/config.d.ts.map +1 -0
  40. package/build/lib/config.js +265 -201
  41. package/build/lib/config.js.map +1 -0
  42. package/build/lib/constants.d.ts +49 -0
  43. package/build/lib/constants.d.ts.map +1 -0
  44. package/build/lib/constants.js +66 -0
  45. package/build/lib/constants.js.map +1 -0
  46. package/build/lib/extension/driver-config.d.ts +82 -0
  47. package/build/lib/extension/driver-config.d.ts.map +1 -0
  48. package/build/lib/extension/driver-config.js +212 -0
  49. package/build/lib/extension/driver-config.js.map +1 -0
  50. package/build/lib/extension/extension-config.d.ts +249 -0
  51. package/build/lib/extension/extension-config.d.ts.map +1 -0
  52. package/build/lib/extension/extension-config.js +581 -0
  53. package/build/lib/extension/extension-config.js.map +1 -0
  54. package/build/lib/extension/index.d.ts +48 -0
  55. package/build/lib/extension/index.d.ts.map +1 -0
  56. package/build/lib/extension/index.js +105 -0
  57. package/build/lib/extension/index.js.map +1 -0
  58. package/build/lib/extension/manifest-migrations.d.ts +27 -0
  59. package/build/lib/extension/manifest-migrations.d.ts.map +1 -0
  60. package/build/lib/extension/manifest-migrations.js +118 -0
  61. package/build/lib/extension/manifest-migrations.js.map +1 -0
  62. package/build/lib/extension/manifest.d.ts +145 -0
  63. package/build/lib/extension/manifest.d.ts.map +1 -0
  64. package/build/lib/extension/manifest.js +521 -0
  65. package/build/lib/extension/manifest.js.map +1 -0
  66. package/build/lib/extension/package-changed.d.ts +11 -0
  67. package/build/lib/extension/package-changed.d.ts.map +1 -0
  68. package/build/lib/extension/package-changed.js +62 -0
  69. package/build/lib/extension/package-changed.js.map +1 -0
  70. package/build/lib/extension/plugin-config.d.ts +56 -0
  71. package/build/lib/extension/plugin-config.d.ts.map +1 -0
  72. package/build/lib/extension/plugin-config.js +102 -0
  73. package/build/lib/extension/plugin-config.js.map +1 -0
  74. package/build/lib/grid-register.d.ts +10 -0
  75. package/build/lib/grid-register.d.ts.map +1 -0
  76. package/build/lib/grid-register.js +122 -144
  77. package/build/lib/grid-register.js.map +1 -0
  78. package/build/lib/logger.d.ts +3 -0
  79. package/build/lib/logger.d.ts.map +1 -0
  80. package/build/lib/logger.js +5 -17
  81. package/build/lib/logger.js.map +1 -0
  82. package/build/lib/logsink.d.ts +4 -0
  83. package/build/lib/logsink.d.ts.map +1 -0
  84. package/build/lib/logsink.js +190 -187
  85. package/build/lib/logsink.js.map +1 -0
  86. package/build/lib/main.d.ts +62 -0
  87. package/build/lib/main.d.ts.map +1 -0
  88. package/build/lib/main.js +348 -228
  89. package/build/lib/main.js.map +1 -0
  90. package/build/lib/schema/arg-spec.d.ts +143 -0
  91. package/build/lib/schema/arg-spec.d.ts.map +1 -0
  92. package/build/lib/schema/arg-spec.js +164 -0
  93. package/build/lib/schema/arg-spec.js.map +1 -0
  94. package/build/lib/schema/cli-args.d.ts +19 -0
  95. package/build/lib/schema/cli-args.d.ts.map +1 -0
  96. package/build/lib/schema/cli-args.js +217 -0
  97. package/build/lib/schema/cli-args.js.map +1 -0
  98. package/build/lib/schema/cli-transformers.d.ts +5 -0
  99. package/build/lib/schema/cli-transformers.d.ts.map +1 -0
  100. package/build/lib/schema/cli-transformers.js +124 -0
  101. package/build/lib/schema/cli-transformers.js.map +1 -0
  102. package/build/lib/schema/index.d.ts +3 -0
  103. package/build/lib/schema/index.d.ts.map +1 -0
  104. package/build/lib/schema/index.js +19 -0
  105. package/build/lib/schema/index.js.map +1 -0
  106. package/build/lib/schema/keywords.d.ts +24 -0
  107. package/build/lib/schema/keywords.d.ts.map +1 -0
  108. package/build/lib/schema/keywords.js +128 -0
  109. package/build/lib/schema/keywords.js.map +1 -0
  110. package/build/lib/schema/schema.d.ts +259 -0
  111. package/build/lib/schema/schema.d.ts.map +1 -0
  112. package/build/lib/schema/schema.js +615 -0
  113. package/build/lib/schema/schema.js.map +1 -0
  114. package/build/lib/utils.d.ts +121 -0
  115. package/build/lib/utils.d.ts.map +1 -0
  116. package/build/lib/utils.js +351 -273
  117. package/build/lib/utils.js.map +1 -0
  118. package/build/tsconfig.tsbuildinfo +1 -0
  119. package/build/types/cli.d.ts +134 -0
  120. package/build/types/cli.d.ts.map +1 -0
  121. package/build/types/cli.js +3 -0
  122. package/build/types/cli.js.map +1 -0
  123. package/build/types/index.d.ts +15 -0
  124. package/build/types/index.d.ts.map +1 -0
  125. package/build/types/index.js +19 -0
  126. package/build/types/index.js.map +1 -0
  127. package/build/types/manifest/base.d.ts +135 -0
  128. package/build/types/manifest/base.d.ts.map +1 -0
  129. package/build/types/manifest/base.js +3 -0
  130. package/build/types/manifest/base.js.map +1 -0
  131. package/build/types/manifest/index.d.ts +19 -0
  132. package/build/types/manifest/index.d.ts.map +1 -0
  133. package/build/types/manifest/index.js +40 -0
  134. package/build/types/manifest/index.js.map +1 -0
  135. package/build/types/manifest/v3.d.ts +139 -0
  136. package/build/types/manifest/v3.d.ts.map +1 -0
  137. package/build/types/manifest/v3.js +3 -0
  138. package/build/types/manifest/v3.js.map +1 -0
  139. package/driver.d.ts +1 -0
  140. package/driver.js +14 -0
  141. package/index.js +11 -0
  142. package/lib/appium.js +535 -186
  143. package/lib/cli/args.js +267 -422
  144. package/lib/cli/driver-command.js +126 -23
  145. package/lib/cli/extension-command.js +679 -271
  146. package/lib/cli/extension.js +48 -17
  147. package/lib/cli/parser.js +263 -83
  148. package/lib/cli/plugin-command.js +115 -20
  149. package/lib/cli/utils.js +24 -10
  150. package/lib/config-file.js +220 -0
  151. package/lib/config.js +244 -110
  152. package/lib/constants.js +71 -0
  153. package/lib/extension/driver-config.js +250 -0
  154. package/lib/extension/extension-config.js +682 -0
  155. package/lib/extension/index.js +116 -0
  156. package/lib/extension/manifest-migrations.js +120 -0
  157. package/lib/extension/manifest.js +573 -0
  158. package/lib/extension/package-changed.js +64 -0
  159. package/lib/extension/plugin-config.js +112 -0
  160. package/lib/grid-register.js +49 -35
  161. package/lib/logger.js +1 -2
  162. package/lib/logsink.js +64 -38
  163. package/lib/main.js +321 -101
  164. package/lib/schema/arg-spec.js +229 -0
  165. package/lib/schema/cli-args.js +238 -0
  166. package/lib/schema/cli-transformers.js +119 -0
  167. package/lib/schema/index.js +2 -0
  168. package/lib/schema/keywords.js +136 -0
  169. package/lib/schema/schema.js +722 -0
  170. package/lib/utils.js +291 -167
  171. package/package.json +83 -84
  172. package/plugin.d.ts +1 -0
  173. package/plugin.js +13 -0
  174. package/scripts/autoinstall-extensions.js +237 -0
  175. package/support.d.ts +1 -0
  176. package/support.js +13 -0
  177. package/tsconfig.json +25 -0
  178. package/types/cli.ts +193 -0
  179. package/types/index.ts +20 -0
  180. package/types/manifest/README.md +30 -0
  181. package/types/manifest/base.ts +158 -0
  182. package/types/manifest/index.ts +27 -0
  183. package/types/manifest/v3.ts +161 -0
  184. package/CHANGELOG.md +0 -3515
  185. package/bin/ios-webkit-debug-proxy-launcher.js +0 -71
  186. package/build/lib/cli/npm.js +0 -208
  187. package/build/lib/cli/parser-helpers.js +0 -82
  188. package/build/lib/driver-config.js +0 -77
  189. package/build/lib/drivers.js +0 -96
  190. package/build/lib/extension-config.js +0 -253
  191. package/build/lib/plugin-config.js +0 -59
  192. package/build/lib/plugins.js +0 -14
  193. package/lib/cli/npm.js +0 -184
  194. package/lib/cli/parser-helpers.js +0 -79
  195. package/lib/driver-config.js +0 -46
  196. package/lib/drivers.js +0 -81
  197. package/lib/extension-config.js +0 -209
  198. package/lib/plugin-config.js +0 -34
  199. package/lib/plugins.js +0 -10
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "appium",
3
+ "version": "2.0.0-beta.53",
3
4
  "description": "Automation for Apps.",
4
- "tags": [
5
+ "keywords": [
5
6
  "automation",
6
7
  "javascript",
7
8
  "selenium",
@@ -11,102 +12,100 @@
11
12
  "firefoxos",
12
13
  "testing"
13
14
  ],
14
- "version": "2.0.0-beta.5",
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",
26
+ "types": "./build/lib/main.d.ts",
29
27
  "bin": {
30
- "appium": "./build/lib/main.js"
28
+ "appium": "index.js"
31
29
  },
32
30
  "directories": {
33
- "lib": "./lib",
34
- "doc": "./docs"
31
+ "lib": "./lib"
35
32
  },
36
33
  "files": [
37
- "bin",
38
34
  "lib",
39
- "build/lib",
40
- "npm-shrinkwrap.json"
35
+ "build",
36
+ "index.js",
37
+ "driver.*",
38
+ "support.*",
39
+ "plugin.*",
40
+ "scripts/autoinstall-extensions.js",
41
+ "types",
42
+ "tsconfig.json"
41
43
  ],
44
+ "scripts": {
45
+ "build:docs": "node docs/scripts/build-docs.js",
46
+ "build:docs:assets": "node docs/scripts/copy-assets.js",
47
+ "build:docs:cli": "node docs/scripts/gen-cli-args-docs.js",
48
+ "build:docs:reference": "node docs/scripts/build-reference.js",
49
+ "dev:docs": "npm run build:docs:assets && npm run dev:docs:en",
50
+ "dev:docs:en": "mkdocs serve -f ./docs/mkdocs-en.yml",
51
+ "dev:docs:ja": "mkdocs serve -f ./docs/mkdocs-ja.yml",
52
+ "dev:docs:zh": "mkdocs serve -f ./docs/mkdocs-zh.yml",
53
+ "postinstall": "node ./scripts/autoinstall-extensions.js",
54
+ "publish:docs": "cross-env APPIUM_DOCS_PUBLISH=1 npm run build:docs",
55
+ "test": "npm run test:unit",
56
+ "test:e2e": "mocha -p --timeout 1m --slow 30s \"./test/e2e/**/*.spec.js\"",
57
+ "test:smoke": "cross-env APPIUM_HOME=./local_appium_home node ./index.js driver install uiautomator2 && cross-env APPIUM_HOME=./local_appium_home node ./index.js driver list",
58
+ "test:unit": "mocha \"./test/unit/**/*.spec.js\""
59
+ },
42
60
  "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"
61
+ "@appium/base-driver": "^9.3.0",
62
+ "@appium/base-plugin": "^2.2.0",
63
+ "@appium/docutils": "^0.1.6",
64
+ "@appium/schema": "^0.2.3",
65
+ "@appium/support": "^3.1.4",
66
+ "@appium/types": "^0.9.0",
67
+ "@sidvind/better-ajv-errors": "2.1.0",
68
+ "@types/argparse": "2.0.10",
69
+ "@types/bluebird": "3.5.38",
70
+ "@types/fancy-log": "2.0.0",
71
+ "@types/semver": "7.3.13",
72
+ "@types/teen_process": "2.0.0",
73
+ "@types/wrap-ansi": "3.0.0",
74
+ "ajv": "8.12.0",
75
+ "ajv-formats": "2.1.1",
76
+ "argparse": "2.0.1",
77
+ "async-lock": "1.4.0",
78
+ "asyncbox": "2.9.4",
79
+ "axios": "1.2.2",
80
+ "bluebird": "3.7.2",
81
+ "cross-env": "7.0.3",
82
+ "find-up": "5.0.0",
83
+ "glob": "8.1.0",
84
+ "lilconfig": "2.0.6",
85
+ "lodash": "4.17.21",
86
+ "longjohn": "0.2.12",
87
+ "npmlog": "7.0.1",
88
+ "ora": "5.4.1",
89
+ "package-changed": "1.9.0",
90
+ "resolve-from": "5.0.0",
91
+ "semver": "7.3.8",
92
+ "source-map-support": "0.5.21",
93
+ "teen_process": "2.0.2",
94
+ "type-fest": "3.5.3",
95
+ "winston": "3.8.2",
96
+ "wrap-ansi": "7.0.0",
97
+ "yaml": "2.2.1"
65
98
  },
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"
99
+ "engines": {
100
+ "node": "^14.17.0 || ^16.13.0 || >=18.0.0",
101
+ "npm": ">=8"
90
102
  },
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"
103
+ "publishConfig": {
104
+ "access": "public",
105
+ "tag": "next"
106
+ },
107
+ "gitHead": "f1e0a46712b76564cd44c37657882308a7bac706",
108
+ "typedoc": {
109
+ "entryPoint": "./lib/main.js"
111
110
  }
112
111
  }
package/plugin.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '@appium/base-plugin';
package/plugin.js ADDED
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ // @ts-check
4
+
5
+ /**
6
+ * This module is here to re-export `@appium/base-plugin` for Appium extensions.
7
+ *
8
+ * @see https://npm.im/@appium/base-plugin
9
+ * @example
10
+ * const { BasePlugin } = require('appium/plugin');
11
+ */
12
+
13
+ module.exports = require('@appium/base-plugin');
@@ -0,0 +1,237 @@
1
+ #!/usr/bin/env node
2
+
3
+ /* eslint-disable no-console, promise/prefer-await-to-then */
4
+
5
+ /**
6
+ * This script is intended to be run as a `postinstall` lifecycle script,
7
+ * and will automatically install extensions if requested by the user.
8
+ *
9
+ * If the current working directory is within a project which has `appium`
10
+ * as a dependency, this script does nothing; extensions must be managed
11
+ * via `npm` or another package manager.
12
+ *
13
+ * If `CI=1` is in the environment, this script will exit with a non-zero
14
+ * code upon failure (which will typically break a build). Otherwise, it
15
+ * will always exit with code 0, even if errors occur.
16
+ *
17
+ * @module
18
+ * @example
19
+ * `npm install -g appium --drivers=uiautomator2,xcuitest --plugins=images`
20
+ */
21
+
22
+ const path = require('path');
23
+ const {exec} = require('teen_process');
24
+ const B = require('bluebird');
25
+
26
+ B.config({
27
+ cancellation: true,
28
+ });
29
+
30
+ /**
31
+ * This is only used if we're actually in the monorepo
32
+ */
33
+ const MONOREPO_ROOT = path.join(__dirname, '..', '..', '..');
34
+
35
+ /** @type {import('../lib/cli/extension').runExtensionCommand} */
36
+ let runExtensionCommand;
37
+ /** @type {import('../lib/constants').DRIVER_TYPE} */
38
+ let DRIVER_TYPE;
39
+ /** @type {import('../lib/constants').PLUGIN_TYPE} */
40
+ let PLUGIN_TYPE;
41
+ /** @type {import('../lib/extension').loadExtensions} */
42
+ let loadExtensions;
43
+
44
+ const _ = require('lodash');
45
+ const wrap = _.partial(
46
+ require('wrap-ansi'),
47
+ _,
48
+ process.stderr.columns ?? process.stdout.columns ?? 80
49
+ );
50
+ const ora = require('ora');
51
+
52
+ let env, util, logger;
53
+
54
+ function log(message) {
55
+ console.error(wrap(`[Appium] ${message}`));
56
+ }
57
+
58
+ async function init() {
59
+ /** @type {import('ora').Ora} */
60
+ let spinner;
61
+
62
+ try {
63
+ ({env, util, logger} = require('@appium/support'));
64
+ require('..');
65
+ } catch {
66
+ spinner = ora({
67
+ text: 'Building Appium dev environment...',
68
+ prefixText: '[Appium]',
69
+ }).start();
70
+
71
+ try {
72
+ const {stderr, code} = await exec('npm', ['run', 'build'], {
73
+ cwd: MONOREPO_ROOT,
74
+ encoding: 'utf8',
75
+ });
76
+ if (!code) {
77
+ spinner.succeed('Appium build successfully.');
78
+ } else {
79
+ spinner.fail(`Building Appium failed!`);
80
+ log(stderr);
81
+ }
82
+ } catch (err) {
83
+ spinner.fail(`Building Appium failed!`);
84
+ log(err);
85
+ }
86
+ }
87
+
88
+ spinner = ora({
89
+ text: 'Checking Appium installation...',
90
+ prefixText: '[Appium]',
91
+ }).start();
92
+
93
+ try {
94
+ ({env, util, logger} = require('@appium/support'));
95
+ ({runExtensionCommand} = require('../build/lib/cli/extension'));
96
+ ({DRIVER_TYPE, PLUGIN_TYPE} = require('../build/lib/constants'));
97
+ ({loadExtensions} = require('../build/lib/extension'));
98
+ spinner.succeed('Appium installation OK');
99
+ // suppress logs from Appium, which mess up the script output
100
+ logger.getLogger('Appium').level = 'error';
101
+ } catch (e) {
102
+ spinner.fail(`Could not load required module(s); has Appium been built? (${e.message})`);
103
+ if (process.env.CI) {
104
+ log('Detected CI environment, exiting with code 1');
105
+ process.exitCode = 1;
106
+ } else {
107
+ process.exitCode = 0;
108
+ }
109
+ return false;
110
+ }
111
+
112
+ return true;
113
+ }
114
+
115
+ async function main() {
116
+ if (!(await init())) {
117
+ return;
118
+ }
119
+
120
+ // if we're doing `npm install -g appium` then we will assume we don't have a local appium.
121
+ if (!process.env.npm_config_global && (await env.hasAppiumDependency())) {
122
+ log(`Found local Appium installation; skipping automatic installation of extensions.`);
123
+ return;
124
+ }
125
+
126
+ const driverEnv = process.env.npm_config_drivers;
127
+ const pluginEnv = process.env.npm_config_plugins;
128
+
129
+ const spinner = ora({
130
+ text: 'Looking for extensions to automatically install...',
131
+ prefixText: '[Appium]',
132
+ }).start();
133
+
134
+ if (!driverEnv && !pluginEnv) {
135
+ spinner.succeed(
136
+ wrap(`No drivers or plugins to automatically install.
137
+ If desired, provide arguments with comma-separated values "--drivers=<known_driver>[,known_driver...]" and/or "--plugins=<known_plugin>[,known_plugin...]" to the "npm install appium" command. The specified extensions will be installed automatically with Appium. Note: to see the list of known extensions, run "appium <driver|plugin> list".`)
138
+ );
139
+ return;
140
+ }
141
+
142
+ const specs = [
143
+ [DRIVER_TYPE, driverEnv],
144
+ [PLUGIN_TYPE, pluginEnv],
145
+ ];
146
+
147
+ spinner.start('Resolving Appium home directory...');
148
+ const appiumHome = await env.resolveAppiumHome();
149
+ spinner.succeed(`Found Appium home: ${appiumHome}`);
150
+
151
+ spinner.start(`Loading extension data...`);
152
+ const {driverConfig, pluginConfig} = await loadExtensions(appiumHome);
153
+ spinner.succeed(`Loaded extension data.`);
154
+
155
+ const installedStats = {[DRIVER_TYPE]: 0, [PLUGIN_TYPE]: 0};
156
+ for (const [type, extEnv] of specs) {
157
+ if (extEnv) {
158
+ for await (let ext of extEnv.split(',')) {
159
+ ext = ext.trim();
160
+ try {
161
+ await checkAndInstallExtension({
162
+ runExtensionCommand,
163
+ appiumHome,
164
+ type,
165
+ ext,
166
+ driverConfig,
167
+ pluginConfig,
168
+ spinner,
169
+ });
170
+ installedStats[type]++;
171
+ } catch (e) {
172
+ spinner.fail(`Could not install ${type} "${ext}": ${e.message}`);
173
+ if (process.env.CI) {
174
+ process.exitCode = 1;
175
+ }
176
+ return;
177
+ }
178
+ }
179
+ }
180
+ }
181
+ spinner.succeed(
182
+ `Done. ${installedStats[DRIVER_TYPE]} ${util.pluralize(
183
+ 'driver',
184
+ installedStats[DRIVER_TYPE]
185
+ )} and ${installedStats[PLUGIN_TYPE]} ${util.pluralize(
186
+ 'plugin',
187
+ installedStats[PLUGIN_TYPE]
188
+ )} are installed.`
189
+ );
190
+ }
191
+
192
+ async function checkAndInstallExtension({
193
+ runExtensionCommand,
194
+ appiumHome,
195
+ type,
196
+ ext,
197
+ driverConfig,
198
+ pluginConfig,
199
+ spinner,
200
+ }) {
201
+ const extList = await runExtensionCommand(
202
+ {
203
+ appiumHome,
204
+ [`${type}Command`]: 'list',
205
+ showInstalled: true,
206
+ suppressOutput: true,
207
+ },
208
+ type === DRIVER_TYPE ? driverConfig : pluginConfig
209
+ );
210
+ if (extList[ext]) {
211
+ spinner.info(`The ${type} "${ext}" is already installed.`);
212
+ return;
213
+ }
214
+ spinner.start(`Installing ${type} "${ext}"...`);
215
+ await runExtensionCommand(
216
+ {
217
+ appiumHome,
218
+ [`${type}Command`]: 'install',
219
+ suppressOutput: true,
220
+ [type]: ext,
221
+ },
222
+ type === DRIVER_TYPE ? driverConfig : pluginConfig
223
+ );
224
+ spinner.succeed(`Installed ${type} "${ext}".`);
225
+ }
226
+
227
+ if (require.main === module) {
228
+ main().catch((e) => {
229
+ log(e);
230
+ if (process.env.CI) {
231
+ log('Detected CI environment, exiting with code 1');
232
+ process.exitCode = 1;
233
+ }
234
+ });
235
+ }
236
+
237
+ module.exports = main;
package/support.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '@appium/support';
package/support.js ADDED
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ // @ts-check
4
+
5
+ /**
6
+ * This module is here to re-export `@appium/support` for Appium extensions.
7
+ *
8
+ * @see https://npm.im/@appium/support
9
+ * @example
10
+ * const { fs, npm } = require('appium/support');
11
+ */
12
+
13
+ module.exports = require('@appium/support');
package/tsconfig.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "extends": "@appium/tsconfig/tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": ".",
5
+ "outDir": "build",
6
+ "paths": {
7
+ "@appium/support": ["../support"],
8
+ "@appium/base-driver": ["../base-driver"],
9
+ "@appium/base-plugin": ["../base-plugin"],
10
+ "@appium/types": ["../types"],
11
+ "@appium/schema": ["../schema"],
12
+ "appium": ["."]
13
+ },
14
+ "checkJs": true
15
+ },
16
+ "include": ["lib", "types"],
17
+ "references": [
18
+ {"path": "../schema"},
19
+ {"path": "../types"},
20
+ {"path": "../support"},
21
+ {"path": "../base-driver"},
22
+ {"path": "../base-plugin"},
23
+ {"path": "../test-support"}
24
+ ]
25
+ }
package/types/cli.ts ADDED
@@ -0,0 +1,193 @@
1
+ import {DriverType, PluginType, ServerArgs} from '@appium/types';
2
+ import {SetOptional} from 'type-fest';
3
+ import {InstallType} from './manifest';
4
+ export type CliCommandServer = 'server';
5
+ export type CliCommandDriver = DriverType;
6
+ export type CliCommandPlugin = PluginType;
7
+
8
+ /**
9
+ * Extension-specific commands
10
+ */
11
+ export type CliExtensionCommand = CliCommandDriver | CliCommandPlugin;
12
+
13
+ /**
14
+ * Possible commands for the `appium` CLI.
15
+ */
16
+ export type CliCommand = CliCommandServer | CliExtensionCommand;
17
+
18
+ /**
19
+ * Possible subcommands of {@linkcode CliCommandDriver} or
20
+ * {@linkcode CliCommandPlugin}.
21
+ */
22
+ export type CliExtensionSubcommand = 'install' | 'list' | 'run' | 'uninstall' | 'update';
23
+
24
+ export interface CliExtensionSubcommandListArgs {
25
+ showInstalled?: boolean;
26
+ showUpdates?: boolean;
27
+ }
28
+
29
+ export interface CliExtensionSubcommandInstallArgs {
30
+ installType: InstallType;
31
+ packageName?: string;
32
+ }
33
+
34
+ export interface CliExtensionSubcommandUpdateArgs {
35
+ unsafe?: boolean;
36
+ }
37
+
38
+ /**
39
+ * Random stuff that may appear in the parsed args which has no equivalent in a
40
+ * config file.
41
+ */
42
+ export interface MoreArgs {
43
+ /**
44
+ * Possible subcommands. If empty, defaults to {@linkcode CliCommandServer}.
45
+ */
46
+ subcommand?: CliCommand;
47
+
48
+ /**
49
+ * Path to config file, if any. Does not make sense for this to be allowed in a config file!
50
+ */
51
+ configFile?: string;
52
+
53
+ /**
54
+ * If true, show the config and exit
55
+ */
56
+ showConfig?: boolean;
57
+
58
+ /**
59
+ * If true, open a REPL
60
+ */
61
+ shell?: boolean;
62
+ }
63
+
64
+ /**
65
+ * These arguments are _not_ supported by the CLI, but only via programmatic usage / tests.
66
+ */
67
+ export interface ProgrammaticArgs {
68
+ /**
69
+ * If `true`, throw on error instead of exit.
70
+ */
71
+ throwInsteadOfExit?: boolean;
72
+
73
+ /**
74
+ * Seems to only be used in tests or standalone driver calls
75
+ */
76
+ logHandler?: (...args: any[]) => void;
77
+
78
+ /**
79
+ * Alternate way to set `APPIUM_HOME` for tests. Since we don't want to muck about
80
+ * with the environment, we just set it here.
81
+ *
82
+ * Setting this means that any discovery of the proper `APPIUM_HOME` path is bypassed
83
+ * and is equivalent to setting `APPIUM_HOME` in the environment.
84
+ */
85
+ appiumHome?: string;
86
+
87
+ /**
88
+ * If true, show the {@link BuildInfo build info} and exit
89
+ */
90
+ showBuildInfo?: boolean;
91
+
92
+ /**
93
+ * If true, show config and exit
94
+ */
95
+ showConfig?: boolean;
96
+ }
97
+
98
+ export interface DriverExtArgs {
99
+ driverCommand: CliExtensionSubcommand;
100
+ driver?: string;
101
+ }
102
+
103
+ export interface PluginExtArgs {
104
+ pluginCommand: CliExtensionSubcommand;
105
+ plugin?: string;
106
+ }
107
+
108
+ /**
109
+ * These are args which the user will specify if using an extension command
110
+ */
111
+ export interface BaseExtArgs<Cmd extends CliExtensionCommand> {
112
+ subcommand: Cmd;
113
+
114
+ /**
115
+ * Output JSON instead of human-readable text
116
+ */
117
+ json?: boolean;
118
+
119
+ /**
120
+ * Output nothing
121
+ */
122
+ suppressOutput?: boolean;
123
+
124
+ /**
125
+ * Extra args to pass to extension scripts
126
+ */
127
+ extraArgs?: string[];
128
+ }
129
+
130
+ /**
131
+ * Args for extension commands; includes a subcommand
132
+ */
133
+ export type ExtArgs<
134
+ Cmd extends CliExtensionCommand,
135
+ SubCmd extends CliExtensionSubcommand
136
+ > = BaseExtArgs<Cmd> &
137
+ (Cmd extends CliCommandDriver
138
+ ? DriverExtArgs
139
+ : Cmd extends CliCommandPlugin
140
+ ? PluginExtArgs
141
+ : never) &
142
+ (SubCmd extends 'install'
143
+ ? CliExtensionSubcommandInstallArgs
144
+ : SubCmd extends 'list'
145
+ ? CliExtensionSubcommandListArgs
146
+ : SubCmd extends 'update'
147
+ ? CliExtensionSubcommandUpdateArgs
148
+ : never);
149
+
150
+ /**
151
+ * Some generic bits of arguments; should not be used outside this declaration
152
+ */
153
+ export type CommonArgs<
154
+ Cmd extends CliCommand = CliCommandServer,
155
+ SubCmd extends CliExtensionSubcommand | void = void
156
+ > = MoreArgs &
157
+ ProgrammaticArgs &
158
+ (Cmd extends CliCommandServer
159
+ ? ServerArgs
160
+ : Cmd extends CliExtensionCommand
161
+ ? SubCmd extends CliExtensionSubcommand
162
+ ? ExtArgs<Cmd, SubCmd>
163
+ : never
164
+ : never);
165
+
166
+ /**
167
+ * Fully-parsed arguments, containing defaults, computed args, and config file values.
168
+ */
169
+ export type ParsedArgs<
170
+ Cmd extends CliCommand = CliCommandServer,
171
+ SubCmd extends CliExtensionSubcommand | void = void
172
+ > = CommonArgs<Cmd, SubCmd>;
173
+
174
+ /**
175
+ * Like {@linkcode ParsedArgs} except server arguments are all optional.
176
+ *
177
+ * _May_ have defaults applied; _may_ contain config values; _may_ contain computed args.
178
+ */
179
+ export type Args<
180
+ Cmd extends CliCommand = CliCommandServer,
181
+ SubCmd extends CliExtensionSubcommand | void = void
182
+ > = Cmd extends CliCommandServer
183
+ ? SetOptional<CommonArgs<Cmd>, keyof ServerArgs>
184
+ : ParsedArgs<Cmd, SubCmd>;
185
+
186
+ /**
187
+ * Shown by `appium --build-info`
188
+ */
189
+ export type BuildInfo = {
190
+ version: string;
191
+ 'git-sha'?: string;
192
+ built?: string;
193
+ };