appium 2.0.0-beta.34 → 2.0.0-beta.38

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 (123) hide show
  1. package/build/lib/appium.d.ts +41 -52
  2. package/build/lib/appium.d.ts.map +1 -1
  3. package/build/lib/appium.js +32 -15
  4. package/build/lib/cli/args.d.ts +1 -1
  5. package/build/lib/cli/args.d.ts.map +1 -1
  6. package/build/lib/cli/args.js +1 -1
  7. package/build/lib/cli/driver-command.d.ts +5 -5
  8. package/build/lib/cli/driver-command.d.ts.map +1 -1
  9. package/build/lib/cli/driver-command.js +8 -8
  10. package/build/lib/cli/extension-command.d.ts +78 -51
  11. package/build/lib/cli/extension-command.d.ts.map +1 -1
  12. package/build/lib/cli/extension-command.js +135 -80
  13. package/build/lib/cli/extension.d.ts +9 -5
  14. package/build/lib/cli/extension.d.ts.map +1 -1
  15. package/build/lib/cli/extension.js +5 -7
  16. package/build/lib/cli/parser.d.ts +3 -3
  17. package/build/lib/cli/parser.d.ts.map +1 -1
  18. package/build/lib/cli/parser.js +1 -1
  19. package/build/lib/cli/plugin-command.d.ts +9 -15
  20. package/build/lib/cli/plugin-command.d.ts.map +1 -1
  21. package/build/lib/cli/plugin-command.js +8 -8
  22. package/build/lib/cli/utils.js +1 -1
  23. package/build/lib/config-file.d.ts.map +1 -1
  24. package/build/lib/config-file.js +1 -1
  25. package/build/lib/config.d.ts +4 -4
  26. package/build/lib/config.d.ts.map +1 -1
  27. package/build/lib/config.js +1 -1
  28. package/build/lib/constants.d.ts.map +1 -1
  29. package/build/lib/constants.js +1 -1
  30. package/build/lib/extension/driver-config.d.ts +29 -32
  31. package/build/lib/extension/driver-config.d.ts.map +1 -1
  32. package/build/lib/extension/driver-config.js +7 -20
  33. package/build/lib/extension/extension-config.d.ts +108 -36
  34. package/build/lib/extension/extension-config.d.ts.map +1 -1
  35. package/build/lib/extension/extension-config.js +199 -60
  36. package/build/lib/extension/index.d.ts +16 -7
  37. package/build/lib/extension/index.d.ts.map +1 -1
  38. package/build/lib/extension/index.js +15 -18
  39. package/build/lib/extension/manifest.d.ts +12 -12
  40. package/build/lib/extension/manifest.d.ts.map +1 -1
  41. package/build/lib/extension/manifest.js +13 -3
  42. package/build/lib/extension/package-changed.d.ts.map +1 -1
  43. package/build/lib/extension/package-changed.js +1 -1
  44. package/build/lib/extension/plugin-config.d.ts +19 -24
  45. package/build/lib/extension/plugin-config.d.ts.map +1 -1
  46. package/build/lib/extension/plugin-config.js +9 -18
  47. package/build/lib/grid-register.d.ts.map +1 -1
  48. package/build/lib/grid-register.js +1 -1
  49. package/build/lib/logger.d.ts +1 -1
  50. package/build/lib/logger.d.ts.map +1 -1
  51. package/build/lib/logger.js +1 -1
  52. package/build/lib/logsink.d.ts.map +1 -1
  53. package/build/lib/logsink.js +3 -2
  54. package/build/lib/main.d.ts +13 -12
  55. package/build/lib/main.d.ts.map +1 -1
  56. package/build/lib/main.js +4 -4
  57. package/build/lib/schema/arg-spec.d.ts +4 -4
  58. package/build/lib/schema/arg-spec.d.ts.map +1 -1
  59. package/build/lib/schema/arg-spec.js +1 -1
  60. package/build/lib/schema/cli-args.d.ts.map +1 -1
  61. package/build/lib/schema/cli-args.js +1 -1
  62. package/build/lib/schema/cli-transformers.d.ts.map +1 -1
  63. package/build/lib/schema/cli-transformers.js +1 -1
  64. package/build/lib/schema/keywords.d.ts.map +1 -1
  65. package/build/lib/schema/keywords.js +1 -1
  66. package/build/lib/schema/schema.d.ts +2 -2
  67. package/build/lib/schema/schema.d.ts.map +1 -1
  68. package/build/lib/schema/schema.js +1 -1
  69. package/build/lib/utils.d.ts.map +1 -1
  70. package/build/lib/utils.js +1 -1
  71. package/build/tsconfig.tsbuildinfo +1 -1
  72. package/build/types/appium-manifest.d.ts +23 -4
  73. package/build/types/appium-manifest.d.ts.map +1 -1
  74. package/build/types/cli.d.ts.map +1 -1
  75. package/build/types/{external-manifest.d.ts → extension-manifest.d.ts} +15 -7
  76. package/build/types/extension-manifest.d.ts.map +1 -0
  77. package/build/types/index.d.ts +6 -5
  78. package/build/types/index.d.ts.map +1 -1
  79. package/driver.d.ts +1 -0
  80. package/driver.js +14 -0
  81. package/lib/appium.js +208 -124
  82. package/lib/cli/args.js +143 -93
  83. package/lib/cli/driver-command.js +46 -26
  84. package/lib/cli/extension-command.js +314 -157
  85. package/lib/cli/extension.js +15 -19
  86. package/lib/cli/parser.js +19 -31
  87. package/lib/cli/plugin-command.js +39 -24
  88. package/lib/cli/utils.js +8 -14
  89. package/lib/config-file.js +21 -25
  90. package/lib/config.js +82 -64
  91. package/lib/constants.js +4 -13
  92. package/lib/extension/driver-config.js +171 -171
  93. package/lib/extension/extension-config.js +347 -126
  94. package/lib/extension/index.js +72 -58
  95. package/lib/extension/manifest.js +48 -57
  96. package/lib/extension/package-changed.js +9 -8
  97. package/lib/extension/plugin-config.js +62 -62
  98. package/lib/grid-register.js +29 -18
  99. package/lib/logger.js +1 -2
  100. package/lib/logsink.js +29 -31
  101. package/lib/main.js +111 -73
  102. package/lib/schema/arg-spec.js +10 -13
  103. package/lib/schema/cli-args.js +14 -37
  104. package/lib/schema/cli-transformers.js +7 -14
  105. package/lib/schema/keywords.js +15 -13
  106. package/lib/schema/schema.js +58 -75
  107. package/lib/utils.js +50 -25
  108. package/package.json +25 -18
  109. package/plugin.d.ts +1 -0
  110. package/plugin.js +13 -0
  111. package/scripts/autoinstall-extensions.js +177 -0
  112. package/support.d.ts +1 -0
  113. package/support.js +13 -0
  114. package/types/appium-manifest.ts +27 -15
  115. package/types/cli.ts +2 -9
  116. package/types/{external-manifest.ts → extension-manifest.ts} +21 -15
  117. package/types/index.ts +12 -5
  118. package/build/types/extension.d.ts +0 -43
  119. package/build/types/extension.d.ts.map +0 -1
  120. package/build/types/external-manifest.d.ts.map +0 -1
  121. package/lib/appium-config.schema.json +0 -278
  122. package/scripts/postinstall.js +0 -71
  123. package/types/extension.ts +0 -56
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium",
3
- "version": "2.0.0-beta.34",
3
+ "version": "2.0.0-beta.38",
4
4
  "description": "Automation for Apps.",
5
5
  "keywords": [
6
6
  "automation",
@@ -23,6 +23,7 @@
23
23
  },
24
24
  "license": "Apache-2.0",
25
25
  "author": "https://github.com/appium",
26
+ "types": "./build/lib/main.d.ts",
26
27
  "bin": {
27
28
  "appium": "index.js"
28
29
  },
@@ -33,33 +34,39 @@
33
34
  "lib",
34
35
  "build",
35
36
  "index.js",
36
- "scripts/postinstall.js",
37
+ "driver.*",
38
+ "support.*",
39
+ "plugin.*",
40
+ "test.*",
41
+ "scripts/autoinstall-extensions.js",
37
42
  "types"
38
43
  ],
39
44
  "scripts": {
40
45
  "build": "babel lib --root-mode=upward --out-dir=build/lib",
41
- "dev": "npm run build -- --watch",
42
- "fix": "npm run lint -- --fix",
43
46
  "build:docs": "node docs/scripts/build-docs.js",
44
47
  "build:docs:assets": "node docs/scripts/copy-assets.js",
48
+ "dev": "npm run build -- --watch",
45
49
  "dev:docs": "npm run build:docs:assets && npm run dev:docs:en",
46
50
  "dev:docs:en": "mkdocs serve -f ./docs/mkdocs-en.yml",
47
51
  "dev:docs:ja": "mkdocs serve -f ./docs/mkdocs-ja.yml",
48
- "publish:docs": "APPIUM_DOCS_PUBLISH=1 npm run build:docs",
49
- "postinstall": "node ./scripts/postinstall.js",
52
+ "fix": "npm run lint -- --fix",
53
+ "postinstall": "node ./scripts/autoinstall-extensions.js",
50
54
  "lint": "eslint -c ../../.eslintrc --ignore-path ../../.eslintignore .",
55
+ "prepare": "npm run build",
56
+ "publish:docs": "APPIUM_DOCS_PUBLISH=1 npm run build:docs",
51
57
  "test": "npm run test:unit",
52
- "test:e2e": "mocha --timeout 30s --slow 15s \"./test/e2e/**/*.spec.js\"",
58
+ "test:e2e": "mocha --timeout 75s --slow 30s \"./test/e2e/**/*.spec.js\"",
53
59
  "test:unit": "mocha \"./test/unit/**/*.spec.js\""
54
60
  },
55
61
  "dependencies": {
56
- "@appium/base-driver": "^8.5.3",
57
- "@appium/base-plugin": "^1.8.5",
58
- "@appium/docutils": "^0.0.4",
59
- "@appium/schema": "^0.0.5",
60
- "@appium/support": "^2.58.0",
61
- "@babel/runtime": "7.17.9",
62
- "@sidvind/better-ajv-errors": "1.1.1",
62
+ "@appium/base-driver": "^8.5.5",
63
+ "@appium/base-plugin": "^1.9.1",
64
+ "@appium/docutils": "^0.0.6",
65
+ "@appium/schema": "^0.0.7",
66
+ "@appium/support": "^2.59.1",
67
+ "@appium/test-support": "^1.3.21",
68
+ "@babel/runtime": "7.18.3",
69
+ "@sidvind/better-ajv-errors": "2.0.0",
63
70
  "ajv": "8.11.0",
64
71
  "ajv-formats": "2.1.1",
65
72
  "argparse": "2.0.1",
@@ -77,19 +84,19 @@
77
84
  "resolve-from": "5.0.0",
78
85
  "semver": "7.3.7",
79
86
  "source-map-support": "0.5.21",
87
+ "supports-color": "8.1.1",
80
88
  "teen_process": "1.16.0",
81
89
  "winston": "3.7.2",
82
90
  "word-wrap": "1.2.3",
83
- "yaml": "2.0.1"
91
+ "yaml": "2.1.1"
84
92
  },
85
93
  "engines": {
86
- "node": ">=12",
94
+ "node": ">=14",
87
95
  "npm": ">=6"
88
96
  },
89
97
  "publishConfig": {
90
98
  "access": "public",
91
99
  "tag": "next"
92
100
  },
93
- "types": "./build/lib/main.d.ts",
94
- "gitHead": "5482c921bc187ed8807922c00bd2355585f4971a"
101
+ "gitHead": "ed2002d90de0b103c35b2feeeeef97f060141a86"
95
102
  }
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,177 @@
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
+ * @example
18
+ * `npm install -g appium --drivers=uiautomator2,xcuitest --plugins=images`
19
+ */
20
+
21
+ /** @type {import('../lib/cli/extension').runExtensionCommand} */
22
+ let runExtensionCommand;
23
+ /** @type {import('../lib/constants').DRIVER_TYPE} */
24
+ let DRIVER_TYPE;
25
+ /** @type {import('../lib/constants').PLUGIN_TYPE} */
26
+ let PLUGIN_TYPE;
27
+ /** @type {import('../lib/extension').loadExtensions} */
28
+ let loadExtensions;
29
+
30
+ const {env, util, logger} = require('@appium/support');
31
+
32
+ const ora = require('ora');
33
+
34
+ const log = (message) => {
35
+ console.error(`[Appium] ${message}`);
36
+ };
37
+
38
+ const spinner = ora({
39
+ text: 'Checking Appium installation...',
40
+ prefixText: '[Appium]',
41
+ }).start();
42
+
43
+ try {
44
+ ({runExtensionCommand} = require('../build/lib/cli/extension'));
45
+ ({DRIVER_TYPE, PLUGIN_TYPE} = require('../build/lib/constants'));
46
+ ({loadExtensions} = require('../build/lib/extension'));
47
+ spinner.succeed('Appium installation OK');
48
+ // suppress logs from Appium, which mess up the script output
49
+ logger.getLogger('Appium').level = 'error';
50
+ } catch (e) {
51
+ spinner.fail(`Could not load required module(s); has Appium been built? (${e.message})`);
52
+ if (process.env.CI) {
53
+ console.error('Detected CI environment, exiting with code 1');
54
+ process.exitCode = 1;
55
+ } else {
56
+ process.exitCode = 0;
57
+ }
58
+ process.exit();
59
+ }
60
+
61
+ async function main() {
62
+ if (await env.hasAppiumDependency()) {
63
+ log(`Found local Appium installation; skipping automatic installation of extensions.`);
64
+ return;
65
+ }
66
+
67
+ const driverEnv = process.env.npm_config_drivers;
68
+ const pluginEnv = process.env.npm_config_plugins;
69
+
70
+ const spinner = ora({
71
+ text: 'Looking for extensions to automatically install...',
72
+ prefixText: '[Appium]',
73
+ }).start();
74
+
75
+ if (!driverEnv && !pluginEnv) {
76
+ spinner.succeed(
77
+ 'No drivers or plugins to automatically install. 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".'
78
+ );
79
+ return;
80
+ }
81
+
82
+ const specs = [
83
+ [DRIVER_TYPE, driverEnv],
84
+ [PLUGIN_TYPE, pluginEnv],
85
+ ];
86
+
87
+ spinner.start('Resolving Appium home directory...');
88
+ const appiumHome = await env.resolveAppiumHome();
89
+ spinner.succeed(`Found Appium home: ${appiumHome}`);
90
+
91
+ spinner.start(`Loading extension data...`);
92
+ const {driverConfig, pluginConfig} = await loadExtensions(appiumHome);
93
+ spinner.succeed(`Loaded extension data.`);
94
+
95
+ const installedStats = {[DRIVER_TYPE]: 0, [PLUGIN_TYPE]: 0};
96
+ for (const [type, extEnv] of specs) {
97
+ if (extEnv) {
98
+ for await (let ext of extEnv.split(',')) {
99
+ ext = ext.trim();
100
+ try {
101
+ await checkAndInstallExtension({
102
+ runExtensionCommand,
103
+ appiumHome,
104
+ type,
105
+ ext,
106
+ driverConfig,
107
+ pluginConfig,
108
+ spinner,
109
+ });
110
+ installedStats[type]++;
111
+ } catch (e) {
112
+ spinner.fail(`Could not install ${type} "${ext}": ${e.message}`);
113
+ if (process.env.CI) {
114
+ process.exitCode = 1;
115
+ }
116
+ return;
117
+ }
118
+ }
119
+ }
120
+ }
121
+ spinner.succeed(
122
+ `Done. ${installedStats[DRIVER_TYPE]} ${util.pluralize(
123
+ 'driver',
124
+ installedStats[DRIVER_TYPE]
125
+ )} and ${installedStats[PLUGIN_TYPE]} ${util.pluralize(
126
+ 'plugin',
127
+ installedStats[PLUGIN_TYPE]
128
+ )} are installed.`
129
+ );
130
+ }
131
+
132
+ async function checkAndInstallExtension({
133
+ runExtensionCommand,
134
+ appiumHome,
135
+ type,
136
+ ext,
137
+ driverConfig,
138
+ pluginConfig,
139
+ spinner,
140
+ }) {
141
+ const extList = await runExtensionCommand(
142
+ {
143
+ appiumHome,
144
+ [`${type}Command`]: 'list',
145
+ showInstalled: true,
146
+ suppressOutput: true,
147
+ },
148
+ type === DRIVER_TYPE ? driverConfig : pluginConfig
149
+ );
150
+ if (extList[ext]) {
151
+ spinner.info(`The ${type} "${ext}" is already installed.`);
152
+ return;
153
+ }
154
+ spinner.start(`Installing ${type} "${ext}"...`);
155
+ await runExtensionCommand(
156
+ {
157
+ appiumHome,
158
+ [`${type}Command`]: 'install',
159
+ suppressOutput: true,
160
+ [type]: ext,
161
+ },
162
+ type === DRIVER_TYPE ? driverConfig : pluginConfig
163
+ );
164
+ spinner.succeed(`Installed ${type} "${ext}".`);
165
+ }
166
+
167
+ if (require.main === module) {
168
+ main().catch((e) => {
169
+ log(e);
170
+ if (process.env.CI) {
171
+ log('Detected CI environment, exiting with code 1');
172
+ process.exitCode = 1;
173
+ }
174
+ });
175
+ }
176
+
177
+ 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');
@@ -1,16 +1,35 @@
1
- import { CommonMetadata, ExtMetadata, SchemaMetadata } from './external-manifest';
2
- import { ExtensionType, DriverType, PluginType } from '.';
1
+ import {CommonExtMetadata, ExtMetadata, ExtSchemaMetadata} from './extension-manifest';
2
+ import {ExtensionType, DriverType, PluginType} from '@appium/types';
3
3
 
4
4
  export type InstallType = 'npm' | 'git' | 'local' | 'github';
5
5
 
6
6
  export interface InternalMetadata {
7
+ /**
8
+ * Package name of extension
9
+ *
10
+ * `name` from its `package.json`
11
+ */
7
12
  pkgName: string;
13
+ /**
14
+ * Version of extension
15
+ *
16
+ * `version` from its `package.json`
17
+ */
8
18
  version: string;
19
+ /**
20
+ * The method in which the user installed the extension (the `source` CLI arg)
21
+ */
9
22
  installType: InstallType;
10
23
  /**
11
24
  * Whatever the user typed as the extension to install. May be derived from `package.json`
12
25
  */
13
26
  installSpec: string;
27
+ /**
28
+ * Maximum version of Appium that this extension is compatible with.
29
+ *
30
+ * If `undefined`, we'll try anyway.
31
+ */
32
+ appiumVersion?: string;
14
33
  }
15
34
 
16
35
  /**
@@ -19,32 +38,25 @@ export interface InternalMetadata {
19
38
  */
20
39
  export type ExtManifest<ExtType extends ExtensionType> = Omit<
21
40
  ExtMetadata<ExtType>,
22
- ExtType extends DriverType
23
- ? 'driverName'
24
- : ExtType extends PluginType
25
- ? 'pluginName'
26
- : never
41
+ ExtType extends DriverType ? 'driverName' : ExtType extends PluginType ? 'pluginName' : never
27
42
  > &
28
43
  InternalMetadata &
29
- CommonMetadata; // XXX: ExtMetadata should be a union with CommonMetadata. why is this needed?
44
+ CommonExtMetadata; // XXX: ExtMetadata should be a union with CommonMetadata. why is this needed?
30
45
 
31
46
  export type WithSchemaManifest = {
32
- schema: SchemaMetadata;
47
+ schema: ExtSchemaMetadata;
33
48
  };
34
49
 
35
50
  /**
36
51
  * This is just a {@linkcode ExtManifest} except it _for sure_ has a `schema` prop.
37
52
  */
38
- export type ExtManifestWithSchema<ExtType extends ExtensionType> =
39
- ExtManifest<ExtType> & WithSchemaManifest;
53
+ export type ExtManifestWithSchema<ExtType extends ExtensionType> = ExtManifest<ExtType> &
54
+ WithSchemaManifest;
40
55
 
41
56
  /**
42
57
  * Generic type for an object keyed by extension name, with values of type {@linkcode ExtData}
43
58
  */
44
- export type ExtRecord<ExtType extends ExtensionType> = Record<
45
- string,
46
- ExtManifest<ExtType>
47
- >;
59
+ export type ExtRecord<ExtType extends ExtensionType> = Record<string, ExtManifest<ExtType>>;
48
60
 
49
61
  export type DriverRecord = ExtRecord<DriverType>;
50
62
  export type PluginRecord = ExtRecord<PluginType>;
package/types/cli.ts CHANGED
@@ -17,10 +17,7 @@ export type PluginSubcommand = typeof PLUGIN_SUBCOMMAND;
17
17
  /**
18
18
  * Possible subcommands for the `appium` CLI.
19
19
  */
20
- export type CliSubcommand =
21
- | ServerSubcommand
22
- | DriverSubcommand
23
- | PluginSubcommand;
20
+ export type CliSubcommand = ServerSubcommand | DriverSubcommand | PluginSubcommand;
24
21
 
25
22
  /**
26
23
  * Possible subcommands of {@linkcode DriverSubcommand} or
@@ -127,11 +124,7 @@ export interface WithExtSubcommand {
127
124
  */
128
125
  type CommonArgs<SArgs, T = WithServerSubcommand> = MoreArgs &
129
126
  ProgrammaticArgs &
130
- (T extends WithServerSubcommand
131
- ? SArgs
132
- : T extends WithExtSubcommand
133
- ? ExtArgs
134
- : never);
127
+ (T extends WithServerSubcommand ? SArgs : T extends WithExtSubcommand ? ExtArgs : never);
135
128
 
136
129
  /**
137
130
  * Fully-parsed arguments, containing defaults, computed args, and config file values.
@@ -2,22 +2,22 @@
2
2
  * These types describe information about external extensions and the contents of their `package.json` files
3
3
  */
4
4
 
5
- import type { SchemaObject } from 'ajv';
6
- import type { PackageJson, SetRequired } from 'type-fest';
7
- import { DriverType, ExtensionType, PluginType } from './index';
5
+ import type {SchemaObject} from 'ajv';
6
+ import type {PackageJson, SetRequired} from 'type-fest';
7
+ import {DriverType, ExtensionType, PluginType} from '@appium/types';
8
8
 
9
9
  /**
10
10
  * This is what is allowed in the `appium.schema` prop of an extension's `package.json`.
11
11
  */
12
- export type SchemaMetadata = string | (SchemaObject & {[key: number]: never});
12
+ export type ExtSchemaMetadata = string | (SchemaObject & {[key: number]: never});
13
13
 
14
14
  /**
15
15
  * Manifest data shared by all extensions, as contained in `package.json`
16
16
  */
17
- export interface CommonMetadata {
17
+ export interface CommonExtMetadata {
18
18
  mainClass: string;
19
19
  scripts?: Record<string, string>;
20
- schema?: SchemaMetadata;
20
+ schema?: ExtSchemaMetadata;
21
21
  }
22
22
 
23
23
  /**
@@ -40,19 +40,25 @@ export interface PluginMetadata {
40
40
  * Generic type to refer to either {@linkcode DriverMetadata} or {@linkcode PluginMetadata}
41
41
  * Corresponds to the `appium` prop in an extension's `package.json`.
42
42
  */
43
- export type ExtMetadata<ExtType extends ExtensionType> =
44
- (ExtType extends DriverType
45
- ? DriverMetadata
46
- : ExtType extends PluginType
47
- ? PluginMetadata
48
- : never) &
49
- CommonMetadata;
43
+ export type ExtMetadata<ExtType extends ExtensionType> = (ExtType extends DriverType
44
+ ? DriverMetadata
45
+ : ExtType extends PluginType
46
+ ? PluginMetadata
47
+ : never) &
48
+ CommonExtMetadata;
50
49
 
51
50
  /**
52
51
  * A `package.json` containing extension metadata.
53
- * Required fields are `name`, `version`, and `appium`.
52
+ * Must have the following properties:
53
+ * - `name`: the name of the extension
54
+ * - `version`: the version of the extension
55
+ * - `appium`: the metadata for the extension
56
+ * - `peerDependencies.appium`: the maximum compatible version of Appium
54
57
  */
55
58
  export type ExtPackageJson<ExtType extends ExtensionType> = SetRequired<
56
59
  PackageJson,
57
60
  'name' | 'version'
58
- > & {appium: ExtMetadata<ExtType>};
61
+ > & {
62
+ appium: ExtMetadata<ExtType>;
63
+ peerDependencies: {appium: string; [key: string]: string};
64
+ };
package/types/index.ts CHANGED
@@ -1,10 +1,8 @@
1
+ import {ExtensionType, DriverType, DriverClass, PluginType, PluginClass} from '@appium/types';
2
+
1
3
  export * from './appium-manifest';
2
- export * from './external-manifest';
3
- export * from './extension';
4
+ export * from './extension-manifest';
4
5
  export * from './cli';
5
- export type DriverType = 'driver';
6
- export type PluginType = 'plugin';
7
- export type ExtensionType = DriverType | PluginType;
8
6
 
9
7
  /**
10
8
  * Known environment variables concerning Appium
@@ -12,3 +10,12 @@ export type ExtensionType = DriverType | PluginType;
12
10
  export interface AppiumEnv extends NodeJS.ProcessEnv {
13
11
  APPIUM_HOME?: string;
14
12
  }
13
+
14
+ /**
15
+ * Generic to get at the class of an extension.
16
+ */
17
+ export type ExtClass<ExtType extends ExtensionType> = ExtType extends DriverType
18
+ ? DriverClass
19
+ : ExtType extends PluginType
20
+ ? PluginClass
21
+ : never;
@@ -1,43 +0,0 @@
1
- import type { BaseDriverBase } from '@appium/base-driver/lib/basedriver/driver';
2
- import { Class, Driver, ExternalDriver } from '@appium/types';
3
- import { DriverType, ExtensionType, PluginType } from '.';
4
- export declare type DriverClass = BaseDriverBase<ExternalDriver, ExternalDriverStatic>;
5
- /**
6
- * Additional static props for external driver classes
7
- */
8
- export interface ExternalDriverStatic {
9
- driverName: string;
10
- }
11
- /**
12
- * TODO: This should be derived from the base plugin.
13
- */
14
- export declare type PluginClass = Class<PluginProto, ExternalPluginStatic>;
15
- /**
16
- * Static props for plugin classes
17
- */
18
- export interface ExternalPluginStatic {
19
- pluginName: string;
20
- }
21
- /**
22
- * A plugin must have this shape.
23
- * @todo Use base plugin instead of this
24
- */
25
- export interface PluginProto {
26
- /**
27
- * I'm not sure why `plugin.name` is required, but it is.
28
- */
29
- name: string;
30
- /**
31
- * Assigned by Appium; _not_ provided by implementor.
32
- */
33
- cliArgs?: Record<string, any>;
34
- /**
35
- * Don't know what this is, but it's also required.
36
- */
37
- onUnexpectedShutdown?: (driver: Driver, cause: Error | string) => Promise<void>;
38
- }
39
- /**
40
- * Generic to get at the class of an extension.
41
- */
42
- export declare type ExtClass<ExtType extends ExtensionType> = ExtType extends DriverType ? DriverClass : ExtType extends PluginType ? PluginClass : never;
43
- //# sourceMappingURL=extension.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../types/extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC;AAE1D,oBAAY,WAAW,GAAG,cAAc,CAAC,cAAc,EACrD,oBAAoB,CAAC,CAAC;AAExB;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,oBAAY,WAAW,GAAG,KAAK,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B;;OAEG;IACH,oBAAoB,CAAC,EAAE,CACrB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,GAAG,MAAM,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB;AAED;;GAEG;AACH,oBAAY,QAAQ,CAAC,OAAO,SAAS,aAAa,IAAI,OAAO,SAAS,UAAU,GAC5E,WAAW,GACX,OAAO,SAAS,UAAU,GAC1B,WAAW,GACX,KAAK,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"external-manifest.d.ts","sourceRoot":"","sources":["../../types/external-manifest.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEhE;;GAEG;AACH,oBAAY,cAAc,GAAG,MAAM,GAAG,CAAC,YAAY,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAA;CAAC,CAAC,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,oBAAY,WAAW,CAAC,OAAO,SAAS,aAAa,IACnD,CAAC,OAAO,SAAS,UAAU,GACvB,cAAc,GACd,OAAO,SAAS,UAAU,GAC1B,cAAc,GACd,KAAK,CAAC,GACR,cAAc,CAAC;AAEnB;;;GAGG;AACH,oBAAY,cAAc,CAAC,OAAO,SAAS,aAAa,IAAI,WAAW,CACrE,WAAW,EACX,MAAM,GAAG,SAAS,CACnB,GAAG;IAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;CAAC,CAAC"}