appium 2.0.0-beta.9 → 2.0.0-rc.2
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.
- package/LICENSE +1 -1
- package/README.md +149 -58
- package/build/lib/appium.d.ts +229 -0
- package/build/lib/appium.d.ts.map +1 -0
- package/build/lib/appium.js +677 -449
- package/build/lib/appium.js.map +1 -0
- package/build/lib/cli/args.d.ts +17 -0
- package/build/lib/cli/args.d.ts.map +1 -0
- package/build/lib/cli/args.js +263 -300
- package/build/lib/cli/args.js.map +1 -0
- package/build/lib/cli/driver-command.d.ts +102 -0
- package/build/lib/cli/driver-command.d.ts.map +1 -0
- package/build/lib/cli/driver-command.js +131 -81
- package/build/lib/cli/driver-command.js.map +1 -0
- package/build/lib/cli/extension-command.d.ts +402 -0
- package/build/lib/cli/extension-command.d.ts.map +1 -0
- package/build/lib/cli/extension-command.js +799 -383
- package/build/lib/cli/extension-command.js.map +1 -0
- package/build/lib/cli/extension.d.ts +23 -0
- package/build/lib/cli/extension.d.ts.map +1 -0
- package/build/lib/cli/extension.js +70 -68
- package/build/lib/cli/extension.js.map +1 -0
- package/build/lib/cli/parser.d.ts +84 -0
- package/build/lib/cli/parser.d.ts.map +1 -0
- package/build/lib/cli/parser.js +252 -148
- package/build/lib/cli/parser.js.map +1 -0
- package/build/lib/cli/plugin-command.d.ts +99 -0
- package/build/lib/cli/plugin-command.d.ts.map +1 -0
- package/build/lib/cli/plugin-command.js +125 -81
- package/build/lib/cli/plugin-command.js.map +1 -0
- package/build/lib/cli/utils.d.ts +29 -0
- package/build/lib/cli/utils.d.ts.map +1 -0
- package/build/lib/cli/utils.js +72 -51
- package/build/lib/cli/utils.js.map +1 -0
- package/build/lib/config-file.d.ts +100 -0
- package/build/lib/config-file.d.ts.map +1 -0
- package/build/lib/config-file.js +207 -0
- package/build/lib/config-file.js.map +1 -0
- package/build/lib/config.d.ts +49 -0
- package/build/lib/config.d.ts.map +1 -0
- package/build/lib/config.js +262 -223
- package/build/lib/config.js.map +1 -0
- package/build/lib/constants.d.ts +56 -0
- package/build/lib/constants.d.ts.map +1 -0
- package/build/lib/constants.js +73 -0
- package/build/lib/constants.js.map +1 -0
- package/build/lib/extension/driver-config.d.ts +82 -0
- package/build/lib/extension/driver-config.d.ts.map +1 -0
- package/build/lib/extension/driver-config.js +210 -0
- package/build/lib/extension/driver-config.js.map +1 -0
- package/build/lib/extension/extension-config.d.ts +270 -0
- package/build/lib/extension/extension-config.d.ts.map +1 -0
- package/build/lib/extension/extension-config.js +601 -0
- package/build/lib/extension/extension-config.js.map +1 -0
- package/build/lib/extension/index.d.ts +48 -0
- package/build/lib/extension/index.d.ts.map +1 -0
- package/build/lib/extension/index.js +105 -0
- package/build/lib/extension/index.js.map +1 -0
- package/build/lib/extension/manifest-migrations.d.ts +27 -0
- package/build/lib/extension/manifest-migrations.d.ts.map +1 -0
- package/build/lib/extension/manifest-migrations.js +134 -0
- package/build/lib/extension/manifest-migrations.js.map +1 -0
- package/build/lib/extension/manifest.d.ts +145 -0
- package/build/lib/extension/manifest.d.ts.map +1 -0
- package/build/lib/extension/manifest.js +528 -0
- package/build/lib/extension/manifest.js.map +1 -0
- package/build/lib/extension/package-changed.d.ts +11 -0
- package/build/lib/extension/package-changed.d.ts.map +1 -0
- package/build/lib/extension/package-changed.js +62 -0
- package/build/lib/extension/package-changed.js.map +1 -0
- package/build/lib/extension/plugin-config.d.ts +56 -0
- package/build/lib/extension/plugin-config.d.ts.map +1 -0
- package/build/lib/extension/plugin-config.js +102 -0
- package/build/lib/extension/plugin-config.js.map +1 -0
- package/build/lib/grid-register.d.ts +10 -0
- package/build/lib/grid-register.d.ts.map +1 -0
- package/build/lib/grid-register.js +122 -144
- package/build/lib/grid-register.js.map +1 -0
- package/build/lib/logger.d.ts +3 -0
- package/build/lib/logger.d.ts.map +1 -0
- package/build/lib/logger.js +5 -17
- package/build/lib/logger.js.map +1 -0
- package/build/lib/logsink.d.ts +4 -0
- package/build/lib/logsink.d.ts.map +1 -0
- package/build/lib/logsink.js +189 -184
- package/build/lib/logsink.js.map +1 -0
- package/build/lib/main.d.ts +62 -0
- package/build/lib/main.d.ts.map +1 -0
- package/build/lib/main.js +406 -234
- package/build/lib/main.js.map +1 -0
- package/build/lib/schema/arg-spec.d.ts +143 -0
- package/build/lib/schema/arg-spec.d.ts.map +1 -0
- package/build/lib/schema/arg-spec.js +164 -0
- package/build/lib/schema/arg-spec.js.map +1 -0
- package/build/lib/schema/cli-args.d.ts +19 -0
- package/build/lib/schema/cli-args.d.ts.map +1 -0
- package/build/lib/schema/cli-args.js +220 -0
- package/build/lib/schema/cli-args.js.map +1 -0
- package/build/lib/schema/cli-transformers.d.ts +5 -0
- package/build/lib/schema/cli-transformers.d.ts.map +1 -0
- package/build/lib/schema/cli-transformers.js +124 -0
- package/build/lib/schema/cli-transformers.js.map +1 -0
- package/build/lib/schema/index.d.ts +3 -0
- package/build/lib/schema/index.d.ts.map +1 -0
- package/build/lib/schema/index.js +19 -0
- package/build/lib/schema/index.js.map +1 -0
- package/build/lib/schema/keywords.d.ts +24 -0
- package/build/lib/schema/keywords.d.ts.map +1 -0
- package/build/lib/schema/keywords.js +128 -0
- package/build/lib/schema/keywords.js.map +1 -0
- package/build/lib/schema/schema.d.ts +260 -0
- package/build/lib/schema/schema.d.ts.map +1 -0
- package/build/lib/schema/schema.js +640 -0
- package/build/lib/schema/schema.js.map +1 -0
- package/build/lib/utils.d.ts +276 -0
- package/build/lib/utils.d.ts.map +1 -0
- package/build/lib/utils.js +372 -192
- package/build/lib/utils.js.map +1 -0
- package/build/types/cli.d.ts +134 -0
- package/build/types/cli.d.ts.map +1 -0
- package/build/types/cli.js +3 -0
- package/build/types/cli.js.map +1 -0
- package/build/types/index.d.ts +15 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/index.js +19 -0
- package/build/types/index.js.map +1 -0
- package/build/types/manifest/base.d.ts +135 -0
- package/build/types/manifest/base.d.ts.map +1 -0
- package/build/types/manifest/base.js +3 -0
- package/build/types/manifest/base.js.map +1 -0
- package/build/types/manifest/index.d.ts +21 -0
- package/build/types/manifest/index.d.ts.map +1 -0
- package/build/types/manifest/index.js +42 -0
- package/build/types/manifest/index.js.map +1 -0
- package/build/types/manifest/v3.d.ts +139 -0
- package/build/types/manifest/v3.d.ts.map +1 -0
- package/build/types/manifest/v3.js +3 -0
- package/build/types/manifest/v3.js.map +1 -0
- package/build/types/manifest/v4.d.ts +139 -0
- package/build/types/manifest/v4.d.ts.map +1 -0
- package/build/types/manifest/v4.js +3 -0
- package/build/types/manifest/v4.js.map +1 -0
- package/driver.d.ts +1 -0
- package/driver.js +14 -0
- package/index.js +11 -0
- package/lib/appium.js +545 -188
- package/lib/cli/args.js +275 -407
- package/lib/cli/driver-command.js +132 -24
- package/lib/cli/extension-command.js +751 -272
- package/lib/cli/extension.js +38 -19
- package/lib/cli/parser.js +267 -95
- package/lib/cli/plugin-command.js +122 -22
- package/lib/cli/utils.js +24 -10
- package/lib/config-file.js +220 -0
- package/lib/config.js +243 -132
- package/lib/constants.js +79 -0
- package/lib/extension/driver-config.js +247 -0
- package/lib/extension/extension-config.js +709 -0
- package/lib/extension/index.js +116 -0
- package/lib/extension/manifest-migrations.js +136 -0
- package/lib/extension/manifest.js +580 -0
- package/lib/extension/package-changed.js +64 -0
- package/lib/extension/plugin-config.js +112 -0
- package/lib/grid-register.js +49 -35
- package/lib/logger.js +1 -2
- package/lib/logsink.js +59 -36
- package/lib/main.js +392 -104
- package/lib/schema/arg-spec.js +229 -0
- package/lib/schema/cli-args.js +241 -0
- package/lib/schema/cli-transformers.js +119 -0
- package/lib/schema/index.js +2 -0
- package/lib/schema/keywords.js +136 -0
- package/lib/schema/schema.js +725 -0
- package/lib/utils.js +310 -89
- package/package.json +84 -84
- package/plugin.d.ts +1 -0
- package/plugin.js +13 -0
- package/scripts/autoinstall-extensions.js +243 -0
- package/support.d.ts +1 -0
- package/support.js +13 -0
- package/tsconfig.json +25 -0
- package/types/cli.ts +193 -0
- package/types/index.ts +20 -0
- package/types/manifest/README.md +30 -0
- package/types/manifest/base.ts +158 -0
- package/types/manifest/index.ts +28 -0
- package/types/manifest/v3.ts +161 -0
- package/types/manifest/v4.ts +161 -0
- package/CHANGELOG.md +0 -3669
- package/bin/ios-webkit-debug-proxy-launcher.js +0 -71
- package/build/lib/cli/argparse-actions.js +0 -104
- package/build/lib/cli/npm.js +0 -207
- package/build/lib/cli/parser-helpers.js +0 -93
- package/build/lib/driver-config.js +0 -77
- package/build/lib/drivers.js +0 -99
- package/build/lib/extension-config.js +0 -253
- package/build/lib/plugin-config.js +0 -59
- package/build/lib/plugins.js +0 -16
- package/build/postinstall.js +0 -90
- package/lib/cli/argparse-actions.js +0 -77
- package/lib/cli/npm.js +0 -183
- package/lib/cli/parser-helpers.js +0 -91
- package/lib/driver-config.js +0 -46
- package/lib/drivers.js +0 -84
- package/lib/extension-config.js +0 -209
- package/lib/plugin-config.js +0 -34
- package/lib/plugins.js +0 -11
- package/postinstall.js +0 -71
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "appium",
|
|
3
|
+
"version": "2.0.0-rc.2",
|
|
3
4
|
"description": "Automation for Apps.",
|
|
4
|
-
"
|
|
5
|
+
"keywords": [
|
|
5
6
|
"automation",
|
|
6
7
|
"javascript",
|
|
7
8
|
"selenium",
|
|
@@ -11,102 +12,101 @@
|
|
|
11
12
|
"firefoxos",
|
|
12
13
|
"testing"
|
|
13
14
|
],
|
|
14
|
-
"
|
|
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
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/appium/appium.git",
|
|
22
|
+
"directory": "packages/appium"
|
|
27
23
|
},
|
|
28
|
-
"
|
|
24
|
+
"license": "Apache-2.0",
|
|
25
|
+
"author": "https://github.com/appium",
|
|
26
|
+
"types": "./build/lib/main.d.ts",
|
|
29
27
|
"bin": {
|
|
30
|
-
"appium": "
|
|
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
|
|
40
|
-
"
|
|
41
|
-
"
|
|
35
|
+
"build",
|
|
36
|
+
"index.js",
|
|
37
|
+
"driver.*",
|
|
38
|
+
"support.*",
|
|
39
|
+
"plugin.*",
|
|
40
|
+
"scripts/autoinstall-extensions.js",
|
|
41
|
+
"types",
|
|
42
|
+
"tsconfig.json",
|
|
43
|
+
"!build/tsconfig.tsbuildinfo"
|
|
42
44
|
],
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build:docs": "node docs/scripts/build-docs.js",
|
|
47
|
+
"build:docs:preview": "cross-env APPIUM_DOCS_PREVIEW=1 npm run build:docs",
|
|
48
|
+
"build:docs:assets": "node docs/scripts/copy-assets.js",
|
|
49
|
+
"build:docs:cli": "node docs/scripts/gen-cli-args-docs.js",
|
|
50
|
+
"build:docs:reference": "node docs/scripts/build-reference.js",
|
|
51
|
+
"dev:docs": "npm run build:docs:assets && npm run dev:docs:en",
|
|
52
|
+
"dev:docs:en": "appium-docs build --serve --mkdocs-yml ./docs/mkdocs-en.yml",
|
|
53
|
+
"dev:docs:ja": "appium-docs build --serve --mkdocs-yml ./docs/mkdocs-ja.yml",
|
|
54
|
+
"dev:docs:zh": "appium-docs build --serve --mkdocs-yml ./docs/mkdocs-zh.yml",
|
|
55
|
+
"postinstall": "node ./scripts/autoinstall-extensions.js",
|
|
56
|
+
"publish:docs": "cross-env APPIUM_DOCS_PUBLISH=1 npm run build:docs",
|
|
57
|
+
"test": "npm run test:unit",
|
|
58
|
+
"test:e2e": "mocha -p --timeout 1m --slow 30s \"./test/e2e/**/*.spec.js\"",
|
|
59
|
+
"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",
|
|
60
|
+
"test:unit": "mocha \"./test/unit/**/*.spec.js\""
|
|
61
|
+
},
|
|
43
62
|
"dependencies": {
|
|
44
|
-
"@appium/base-
|
|
45
|
-
"@
|
|
46
|
-
"appium
|
|
47
|
-
"appium
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"bluebird": "3.
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
63
|
+
"@appium/base-driver": "^9.3.12",
|
|
64
|
+
"@appium/base-plugin": "^2.2.12",
|
|
65
|
+
"@appium/docutils": "^0.4.1",
|
|
66
|
+
"@appium/schema": "^0.3.0",
|
|
67
|
+
"@appium/support": "^4.0.3",
|
|
68
|
+
"@appium/types": "^0.12.0",
|
|
69
|
+
"@sidvind/better-ajv-errors": "2.1.0",
|
|
70
|
+
"@types/argparse": "2.0.10",
|
|
71
|
+
"@types/bluebird": "3.5.38",
|
|
72
|
+
"@types/fancy-log": "2.0.0",
|
|
73
|
+
"@types/semver": "7.5.0",
|
|
74
|
+
"@types/teen_process": "2.0.0",
|
|
75
|
+
"@types/wrap-ansi": "3.0.0",
|
|
76
|
+
"ajv": "8.12.0",
|
|
77
|
+
"ajv-formats": "2.1.1",
|
|
78
|
+
"argparse": "2.0.1",
|
|
79
|
+
"async-lock": "1.4.0",
|
|
80
|
+
"asyncbox": "2.9.4",
|
|
81
|
+
"axios": "1.4.0",
|
|
82
|
+
"bluebird": "3.7.2",
|
|
83
|
+
"cross-env": "7.0.3",
|
|
84
|
+
"find-up": "5.0.0",
|
|
85
|
+
"glob": "8.1.0",
|
|
86
|
+
"lilconfig": "2.1.0",
|
|
87
|
+
"lodash": "4.17.21",
|
|
88
|
+
"npmlog": "7.0.1",
|
|
89
|
+
"ora": "5.4.1",
|
|
90
|
+
"package-changed": "3.0.0",
|
|
91
|
+
"resolve-from": "5.0.0",
|
|
92
|
+
"semver": "7.5.1",
|
|
93
|
+
"source-map-support": "0.5.21",
|
|
94
|
+
"teen_process": "2.0.2",
|
|
95
|
+
"type-fest": "3.11.1",
|
|
96
|
+
"winston": "3.9.0",
|
|
97
|
+
"wrap-ansi": "7.0.0",
|
|
98
|
+
"yaml": "2.3.1"
|
|
65
99
|
},
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
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
|
-
"postinstall": "node ./postinstall.js",
|
|
76
|
-
"test": "gulp once",
|
|
77
|
-
"e2e-test": "gulp e2e-test",
|
|
78
|
-
"watch": "gulp watch",
|
|
79
|
-
"build": "gulp transpile",
|
|
80
|
-
"mocha": "mocha",
|
|
81
|
-
"precommit-msg": "echo 'Pre-commit checks...' && exit 0",
|
|
82
|
-
"precommit-test": "REPORTER=dot gulp once",
|
|
83
|
-
"lint": "gulp lint",
|
|
84
|
-
"lint:fix": "gulp lint --fix",
|
|
85
|
-
"coverage": "gulp coveralls",
|
|
86
|
-
"generate-docs": "node ./build/commands-yml/parse.js",
|
|
87
|
-
"zip": "zip -qr appium.zip .",
|
|
88
|
-
"upload": "gulp github-upload",
|
|
89
|
-
"zip-and-upload": "npm run zip && npm run upload"
|
|
100
|
+
"engines": {
|
|
101
|
+
"node": "^14.17.0 || ^16.13.0 || >=18.0.0",
|
|
102
|
+
"npm": ">=8"
|
|
90
103
|
},
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
|
|
95
|
-
"
|
|
96
|
-
|
|
97
|
-
"
|
|
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
|
-
"webdriverio": "^6.12.0",
|
|
110
|
-
"yaml-js": "^0.2.0"
|
|
104
|
+
"publishConfig": {
|
|
105
|
+
"access": "public",
|
|
106
|
+
"tag": "next"
|
|
107
|
+
},
|
|
108
|
+
"gitHead": "af066eb5c3542338eec821b81d6aa4bcf2d81188",
|
|
109
|
+
"typedoc": {
|
|
110
|
+
"entryPoint": "./lib/main.js"
|
|
111
111
|
}
|
|
112
112
|
}
|
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,243 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// @ts-check
|
|
4
|
+
|
|
5
|
+
/* eslint-disable no-console, promise/prefer-await-to-then */
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* This script is intended to be run as a `postinstall` lifecycle script,
|
|
9
|
+
* and will automatically install extensions if requested by the user.
|
|
10
|
+
*
|
|
11
|
+
* If the current working directory is within a project which has `appium`
|
|
12
|
+
* as a dependency, this script does nothing; extensions must be managed
|
|
13
|
+
* via `npm` or another package manager.
|
|
14
|
+
*
|
|
15
|
+
* If `CI=1` is in the environment, this script will exit with a non-zero
|
|
16
|
+
* code upon failure (which will typically break a build). Otherwise, it
|
|
17
|
+
* will always exit with code 0, even if errors occur.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
* @example
|
|
21
|
+
* `npm install -g appium --drivers=uiautomator2,xcuitest --plugins=images`
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const B = require('bluebird');
|
|
25
|
+
const path = require('node:path');
|
|
26
|
+
const {realpath} = require('node:fs/promises');
|
|
27
|
+
|
|
28
|
+
B.config({
|
|
29
|
+
cancellation: true,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
/** @type {typeof import('../lib/cli/extension').runExtensionCommand} */
|
|
33
|
+
let runExtensionCommand;
|
|
34
|
+
/** @type {typeof import('../lib/constants').DRIVER_TYPE} */
|
|
35
|
+
let DRIVER_TYPE;
|
|
36
|
+
/** @type {typeof import('../lib/constants').PLUGIN_TYPE} */
|
|
37
|
+
let PLUGIN_TYPE;
|
|
38
|
+
/** @type {typeof import('../lib/extension').loadExtensions} */
|
|
39
|
+
let loadExtensions;
|
|
40
|
+
|
|
41
|
+
const _ = require('lodash');
|
|
42
|
+
const wrap = _.partial(
|
|
43
|
+
require('wrap-ansi'),
|
|
44
|
+
_,
|
|
45
|
+
process.stderr.columns ?? process.stdout.columns ?? 80
|
|
46
|
+
);
|
|
47
|
+
const ora = require('ora');
|
|
48
|
+
|
|
49
|
+
/** @type {typeof import('@appium/support').env} */
|
|
50
|
+
let env;
|
|
51
|
+
/** @type {typeof import('@appium/support').util} */
|
|
52
|
+
let util;
|
|
53
|
+
/** @type {typeof import('@appium/support').logger} */
|
|
54
|
+
let logger;
|
|
55
|
+
|
|
56
|
+
function log(message) {
|
|
57
|
+
console.error(wrap(`[Appium] ${message}`));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* This is a naive attempt at determining whether or not we are in a dev environment; in other
|
|
62
|
+
* words, is `postinstall` being run from within the `appium` monorepo?
|
|
63
|
+
*
|
|
64
|
+
* When we're in the monorepo, `npm_config_local_prefix` will be set to the root of the monorepo root
|
|
65
|
+
* dir when running this lifecycle script from an `npm install` in the monorepo root.
|
|
66
|
+
*
|
|
67
|
+
* `realpath` is necessary due to macOS omitting `/private` from paths
|
|
68
|
+
*/
|
|
69
|
+
async function isDevEnvironment() {
|
|
70
|
+
return (
|
|
71
|
+
process.env.npm_config_local_prefix &&
|
|
72
|
+
path.join(process.env.npm_config_local_prefix, 'packages', 'appium') ===
|
|
73
|
+
(await realpath(path.join(__dirname, '..')))
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Setup / check environment if we should do anything here
|
|
79
|
+
* @returns {Promise<boolean>} `true` if Appium is built and ready to go
|
|
80
|
+
*/
|
|
81
|
+
async function init() {
|
|
82
|
+
if (await isDevEnvironment()) {
|
|
83
|
+
log('Dev environment likely; skipping automatic installation of extensions');
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
({env, util, logger} = require('@appium/support'));
|
|
88
|
+
// @ts-ignore
|
|
89
|
+
({runExtensionCommand} = require('../build/lib/cli/extension'));
|
|
90
|
+
({DRIVER_TYPE, PLUGIN_TYPE} = require('../build/lib/constants'));
|
|
91
|
+
// @ts-ignore
|
|
92
|
+
({loadExtensions} = require('../build/lib/extension'));
|
|
93
|
+
logger.getLogger('Appium').level = 'error';
|
|
94
|
+
|
|
95
|
+
// if we're doing `npm install -g appium` then we will assume we don't have a local appium.
|
|
96
|
+
if (!process.env.npm_config_global && (await env.hasAppiumDependency(process.cwd()))) {
|
|
97
|
+
log(`Found local Appium installation; skipping automatic installation of extensions.`);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
return true;
|
|
101
|
+
} catch {
|
|
102
|
+
log('Dev environment likely; skipping automatic installation of extensions');
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async function main() {
|
|
108
|
+
if (!(await init())) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const driverEnv = process.env.npm_config_drivers;
|
|
113
|
+
const pluginEnv = process.env.npm_config_plugins;
|
|
114
|
+
|
|
115
|
+
const spinner = ora({
|
|
116
|
+
text: 'Looking for extensions to automatically install...',
|
|
117
|
+
prefixText: '[Appium]',
|
|
118
|
+
}).start();
|
|
119
|
+
|
|
120
|
+
if (!driverEnv && !pluginEnv) {
|
|
121
|
+
spinner.succeed(
|
|
122
|
+
wrap(`No drivers or plugins to automatically install.
|
|
123
|
+
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".`)
|
|
124
|
+
);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @type {[[typeof DRIVER_TYPE, string?], [typeof PLUGIN_TYPE, string?]]}
|
|
130
|
+
*/
|
|
131
|
+
const specs = [
|
|
132
|
+
[DRIVER_TYPE, driverEnv],
|
|
133
|
+
[PLUGIN_TYPE, pluginEnv],
|
|
134
|
+
];
|
|
135
|
+
|
|
136
|
+
spinner.start('Resolving Appium home directory...');
|
|
137
|
+
const appiumHome = await env.resolveAppiumHome();
|
|
138
|
+
spinner.succeed(`Found Appium home: ${appiumHome}`);
|
|
139
|
+
|
|
140
|
+
spinner.start('Loading extension data...');
|
|
141
|
+
const {driverConfig, pluginConfig} = await loadExtensions(appiumHome);
|
|
142
|
+
spinner.succeed('Loaded extension data.');
|
|
143
|
+
|
|
144
|
+
const installedStats = {[DRIVER_TYPE]: 0, [PLUGIN_TYPE]: 0};
|
|
145
|
+
for (const [type, extEnv] of specs) {
|
|
146
|
+
if (extEnv) {
|
|
147
|
+
for await (let ext of extEnv.split(',')) {
|
|
148
|
+
ext = ext.trim();
|
|
149
|
+
try {
|
|
150
|
+
await checkAndInstallExtension({
|
|
151
|
+
runExtensionCommand,
|
|
152
|
+
appiumHome,
|
|
153
|
+
type,
|
|
154
|
+
ext,
|
|
155
|
+
driverConfig,
|
|
156
|
+
pluginConfig,
|
|
157
|
+
spinner,
|
|
158
|
+
});
|
|
159
|
+
installedStats[type]++;
|
|
160
|
+
} catch (e) {
|
|
161
|
+
spinner.fail(`Could not install ${type} "${ext}": ${e.message}`);
|
|
162
|
+
if (process.env.CI) {
|
|
163
|
+
process.exitCode = 1;
|
|
164
|
+
}
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
spinner.succeed(
|
|
171
|
+
`Done. ${installedStats[DRIVER_TYPE]} ${util.pluralize(
|
|
172
|
+
'driver',
|
|
173
|
+
installedStats[DRIVER_TYPE]
|
|
174
|
+
)} and ${installedStats[PLUGIN_TYPE]} ${util.pluralize(
|
|
175
|
+
'plugin',
|
|
176
|
+
installedStats[PLUGIN_TYPE]
|
|
177
|
+
)} are installed.`
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @privateRemarks the two `@ts-ignore` directives here are because I have no idea what's wrong with
|
|
183
|
+
* the types and don't want to spend more time on it. regardless, it seems to work for now.
|
|
184
|
+
* @param {CheckAndInstallExtensionsOpts} opts
|
|
185
|
+
*/
|
|
186
|
+
async function checkAndInstallExtension({
|
|
187
|
+
runExtensionCommand,
|
|
188
|
+
appiumHome,
|
|
189
|
+
type,
|
|
190
|
+
ext,
|
|
191
|
+
driverConfig,
|
|
192
|
+
pluginConfig,
|
|
193
|
+
spinner,
|
|
194
|
+
}) {
|
|
195
|
+
const extList = await runExtensionCommand(
|
|
196
|
+
// @ts-ignore
|
|
197
|
+
{
|
|
198
|
+
appiumHome,
|
|
199
|
+
subcommand: type,
|
|
200
|
+
[`${type}Command`]: 'list',
|
|
201
|
+
showInstalled: true,
|
|
202
|
+
suppressOutput: true,
|
|
203
|
+
},
|
|
204
|
+
type === DRIVER_TYPE ? driverConfig : pluginConfig
|
|
205
|
+
);
|
|
206
|
+
if (extList[ext]) {
|
|
207
|
+
spinner.info(`The ${type} "${ext}" is already installed.`);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
spinner.start(`Installing ${type} "${ext}"...`);
|
|
211
|
+
await runExtensionCommand(
|
|
212
|
+
// @ts-ignore
|
|
213
|
+
{
|
|
214
|
+
subcommand: type,
|
|
215
|
+
appiumHome,
|
|
216
|
+
[`${type}Command`]: 'install',
|
|
217
|
+
suppressOutput: true,
|
|
218
|
+
[type]: ext,
|
|
219
|
+
},
|
|
220
|
+
type === DRIVER_TYPE ? driverConfig : pluginConfig
|
|
221
|
+
);
|
|
222
|
+
spinner.succeed(`Installed ${type} "${ext}".`);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (require.main === module) {
|
|
226
|
+
main().catch((e) => {
|
|
227
|
+
log(e);
|
|
228
|
+
process.exitCode = 1;
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
module.exports = main;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* @typedef CheckAndInstallExtensionsOpts
|
|
236
|
+
* @property {typeof runExtensionCommand} runExtensionCommand
|
|
237
|
+
* @property {string} appiumHome
|
|
238
|
+
* @property {DRIVER_TYPE | PLUGIN_TYPE} type
|
|
239
|
+
* @property {string} ext
|
|
240
|
+
* @property {import('../lib/extension/driver-config').DriverConfig} driverConfig
|
|
241
|
+
* @property {import('../lib/extension/plugin-config').PluginConfig} pluginConfig
|
|
242
|
+
* @property {import('ora').Ora} spinner
|
|
243
|
+
*/
|
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
|
+
};
|