appium 2.0.0-beta.4 → 2.0.0-beta.40

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 (151) hide show
  1. package/README.md +10 -11
  2. package/build/lib/appium.d.ts +204 -0
  3. package/build/lib/appium.d.ts.map +1 -0
  4. package/build/lib/appium.js +257 -131
  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 +25 -18
  11. package/build/lib/cli/extension-command.d.ts +372 -0
  12. package/build/lib/cli/extension-command.d.ts.map +1 -0
  13. package/build/lib/cli/extension-command.js +286 -156
  14. package/build/lib/cli/extension.d.ts +18 -0
  15. package/build/lib/cli/extension.d.ts.map +1 -0
  16. package/build/lib/cli/extension.js +30 -17
  17. package/build/lib/cli/parser.d.ts +80 -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 +33 -0
  21. package/build/lib/cli/plugin-command.d.ts.map +1 -0
  22. package/build/lib/cli/plugin-command.js +24 -19
  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 +41 -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 +81 -0
  36. package/build/lib/extension/driver-config.d.ts.map +1 -0
  37. package/build/lib/extension/driver-config.js +177 -0
  38. package/build/lib/extension/extension-config.d.ts +242 -0
  39. package/build/lib/extension/extension-config.d.ts.map +1 -0
  40. package/build/lib/extension/extension-config.js +436 -0
  41. package/build/lib/extension/index.d.ts +48 -0
  42. package/build/lib/extension/index.d.ts.map +1 -0
  43. package/build/lib/extension/index.js +74 -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 +256 -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 +57 -0
  51. package/build/lib/extension/plugin-config.d.ts.map +1 -0
  52. package/build/lib/extension/plugin-config.js +78 -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 +14 -17
  62. package/build/lib/main.d.ts +55 -0
  63. package/build/lib/main.d.ts.map +1 -0
  64. package/build/lib/main.js +189 -90
  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/build/types/appium-manifest.d.ts +59 -0
  88. package/build/types/appium-manifest.d.ts.map +1 -0
  89. package/build/types/cli.d.ts +112 -0
  90. package/build/types/cli.d.ts.map +1 -0
  91. package/build/types/extension-manifest.d.ts +55 -0
  92. package/build/types/extension-manifest.d.ts.map +1 -0
  93. package/build/types/index.d.ts +16 -0
  94. package/build/types/index.d.ts.map +1 -0
  95. package/driver.d.ts +1 -0
  96. package/driver.js +14 -0
  97. package/index.js +11 -0
  98. package/lib/appium.js +517 -186
  99. package/lib/cli/args.js +269 -422
  100. package/lib/cli/driver-command.js +58 -23
  101. package/lib/cli/extension-command.js +612 -260
  102. package/lib/cli/extension.js +34 -16
  103. package/lib/cli/parser.js +241 -83
  104. package/lib/cli/plugin-command.js +48 -20
  105. package/lib/cli/utils.js +24 -10
  106. package/lib/config-file.js +219 -0
  107. package/lib/config.js +210 -91
  108. package/lib/constants.js +69 -0
  109. package/lib/extension/driver-config.js +249 -0
  110. package/lib/extension/extension-config.js +679 -0
  111. package/lib/extension/index.js +116 -0
  112. package/lib/extension/manifest.js +475 -0
  113. package/lib/extension/package-changed.js +64 -0
  114. package/lib/extension/plugin-config.js +113 -0
  115. package/lib/grid-register.js +49 -35
  116. package/lib/logger.js +1 -2
  117. package/lib/logsink.js +38 -33
  118. package/lib/main.js +303 -100
  119. package/lib/schema/arg-spec.js +229 -0
  120. package/lib/schema/cli-args.js +238 -0
  121. package/lib/schema/cli-transformers.js +115 -0
  122. package/lib/schema/index.js +2 -0
  123. package/lib/schema/keywords.js +136 -0
  124. package/lib/schema/schema.js +717 -0
  125. package/lib/utils.js +121 -140
  126. package/package.json +75 -85
  127. package/plugin.d.ts +1 -0
  128. package/plugin.js +13 -0
  129. package/scripts/autoinstall-extensions.js +177 -0
  130. package/support.d.ts +1 -0
  131. package/support.js +13 -0
  132. package/types/appium-manifest.ts +73 -0
  133. package/types/cli.ts +146 -0
  134. package/types/extension-manifest.ts +64 -0
  135. package/types/index.ts +21 -0
  136. package/CHANGELOG.md +0 -3515
  137. package/bin/ios-webkit-debug-proxy-launcher.js +0 -71
  138. package/build/lib/cli/npm.js +0 -206
  139. package/build/lib/cli/parser-helpers.js +0 -82
  140. package/build/lib/driver-config.js +0 -77
  141. package/build/lib/drivers.js +0 -96
  142. package/build/lib/extension-config.js +0 -253
  143. package/build/lib/plugin-config.js +0 -59
  144. package/build/lib/plugins.js +0 -14
  145. package/lib/cli/npm.js +0 -183
  146. package/lib/cli/parser-helpers.js +0 -79
  147. package/lib/driver-config.js +0 -46
  148. package/lib/drivers.js +0 -81
  149. package/lib/extension-config.js +0 -209
  150. package/lib/plugin-config.js +0 -34
  151. package/lib/plugins.js +0 -10
@@ -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');
@@ -0,0 +1,73 @@
1
+ import {CommonExtMetadata, ExtMetadata, ExtSchemaMetadata} from './extension-manifest';
2
+ import {ExtensionType, DriverType, PluginType} from '@appium/types';
3
+
4
+ export type InstallType = 'npm' | 'git' | 'local' | 'github';
5
+
6
+ export interface InternalMetadata {
7
+ /**
8
+ * Package name of extension
9
+ *
10
+ * `name` from its `package.json`
11
+ */
12
+ pkgName: string;
13
+ /**
14
+ * Version of extension
15
+ *
16
+ * `version` from its `package.json`
17
+ */
18
+ version: string;
19
+ /**
20
+ * The method in which the user installed the extension (the `source` CLI arg)
21
+ */
22
+ installType: InstallType;
23
+ /**
24
+ * Whatever the user typed as the extension to install. May be derived from `package.json`
25
+ */
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;
33
+ }
34
+
35
+ /**
36
+ * Combination of external + internal extension data with `driverName`/`pluginName` removed (it becomes a key in an {@linkcode ExtRecord} object).
37
+ * Part of `extensions.yaml`.
38
+ */
39
+ export type ExtManifest<ExtType extends ExtensionType> = Omit<
40
+ ExtMetadata<ExtType>,
41
+ ExtType extends DriverType ? 'driverName' : ExtType extends PluginType ? 'pluginName' : never
42
+ > &
43
+ InternalMetadata &
44
+ CommonExtMetadata; // XXX: ExtMetadata should be a union with CommonMetadata. why is this needed?
45
+
46
+ export type WithSchemaManifest = {
47
+ schema: ExtSchemaMetadata;
48
+ };
49
+
50
+ /**
51
+ * This is just a {@linkcode ExtManifest} except it _for sure_ has a `schema` prop.
52
+ */
53
+ export type ExtManifestWithSchema<ExtType extends ExtensionType> = ExtManifest<ExtType> &
54
+ WithSchemaManifest;
55
+
56
+ /**
57
+ * Generic type for an object keyed by extension name, with values of type {@linkcode ExtData}
58
+ */
59
+ export type ExtRecord<ExtType extends ExtensionType> = Record<string, ExtManifest<ExtType>>;
60
+
61
+ export type DriverRecord = ExtRecord<DriverType>;
62
+ export type PluginRecord = ExtRecord<PluginType>;
63
+
64
+ export type ExtName<ExtType extends ExtensionType> = keyof ExtRecord<ExtType>;
65
+
66
+ /**
67
+ * Represents an entire YAML manifest (`extensions.yaml`)
68
+ */
69
+ export interface ManifestData {
70
+ drivers: DriverRecord;
71
+ plugins: PluginRecord;
72
+ schemaRev?: number;
73
+ }
package/types/cli.ts ADDED
@@ -0,0 +1,146 @@
1
+ import {ServerArgs} from '@appium/types';
2
+ import type {
3
+ DRIVER_TYPE as DRIVER_SUBCOMMAND,
4
+ EXT_SUBCOMMAND_INSTALL,
5
+ EXT_SUBCOMMAND_LIST,
6
+ EXT_SUBCOMMAND_RUN,
7
+ EXT_SUBCOMMAND_UNINSTALL,
8
+ EXT_SUBCOMMAND_UPDATE,
9
+ PLUGIN_TYPE as PLUGIN_SUBCOMMAND,
10
+ SERVER_SUBCOMMAND,
11
+ } from '../lib/constants';
12
+
13
+ export type ServerSubcommand = typeof SERVER_SUBCOMMAND;
14
+ export type DriverSubcommand = typeof DRIVER_SUBCOMMAND;
15
+ export type PluginSubcommand = typeof PLUGIN_SUBCOMMAND;
16
+
17
+ /**
18
+ * Possible subcommands for the `appium` CLI.
19
+ */
20
+ export type CliSubcommand = ServerSubcommand | DriverSubcommand | PluginSubcommand;
21
+
22
+ /**
23
+ * Possible subcommands of {@linkcode DriverSubcommand} or
24
+ * {@linkcode PluginSubcommand}.
25
+ */
26
+ export type CliExtensionSubcommand =
27
+ | typeof EXT_SUBCOMMAND_INSTALL
28
+ | typeof EXT_SUBCOMMAND_LIST
29
+ | typeof EXT_SUBCOMMAND_RUN
30
+ | typeof EXT_SUBCOMMAND_UPDATE
31
+ | typeof EXT_SUBCOMMAND_UNINSTALL;
32
+
33
+ /**
34
+ * Random stuff that may appear in the parsed args which has no equivalent in a
35
+ * config file.
36
+ */
37
+ export interface MoreArgs {
38
+ /**
39
+ * Possible subcommands. If empty, defaults to {@linkcode ServerSubcommand}.
40
+ */
41
+ subcommand?: CliSubcommand;
42
+
43
+ /**
44
+ * Path to config file, if any. Does not make sense for this to be allowed in a config file!
45
+ */
46
+ configFile?: string;
47
+
48
+ /**
49
+ * If true, show the config and exit
50
+ */
51
+ showConfig?: boolean;
52
+
53
+ /**
54
+ * If true, open a REPL
55
+ */
56
+ shell?: boolean;
57
+ }
58
+
59
+ /**
60
+ * These arguments are _not_ supported by the CLI, but only via programmatic usage / tests.
61
+ */
62
+ export interface ProgrammaticArgs {
63
+ /**
64
+ * If `true`, throw on error instead of exit.
65
+ */
66
+ throwInsteadOfExit?: boolean;
67
+
68
+ /**
69
+ * Seems to only be used in tests or standalone driver calls
70
+ */
71
+ logHandler?: (...args: any[]) => void;
72
+
73
+ /**
74
+ * Alternate way to set `APPIUM_HOME` for tests. Since we don't want to muck about
75
+ * with the environment, we just set it here.
76
+ *
77
+ * Setting this means that any discovery of the proper `APPIUM_HOME` path is bypassed
78
+ * and is equivalent to setting `APPIUM_HOME` in the environment.
79
+ */
80
+ appiumHome?: string;
81
+
82
+ /**
83
+ * If true, show the {@link BuildInfo build info} and exit
84
+ */
85
+ showBuildInfo?: boolean;
86
+
87
+ /**
88
+ * If true, show config and exit
89
+ */
90
+ showConfig?: boolean;
91
+ }
92
+
93
+ /**
94
+ * These are args which the user will specify if using an extension command
95
+ */
96
+ export interface ExtArgs extends WithExtSubcommand {
97
+ /**
98
+ * Subcommands of `driver` subcommand
99
+ */
100
+ driverCommand?: CliExtensionSubcommand;
101
+
102
+ /**
103
+ * Subcommands of `plugin` subcommand
104
+ */
105
+ pluginCommand?: CliExtensionSubcommand;
106
+ }
107
+
108
+ /**
109
+ * Args having the `server` subcommand
110
+ */
111
+ export interface WithServerSubcommand {
112
+ subcommand?: ServerSubcommand;
113
+ }
114
+
115
+ /**
116
+ * Args having the `driver` or `plugin` subcommand
117
+ */
118
+ export interface WithExtSubcommand {
119
+ subcommand: DriverSubcommand | PluginSubcommand;
120
+ }
121
+
122
+ /**
123
+ * Some generic bits of arguments; should not be used outside this declaration
124
+ */
125
+ type CommonArgs<SArgs, T = WithServerSubcommand> = MoreArgs &
126
+ ProgrammaticArgs &
127
+ (T extends WithServerSubcommand ? SArgs : T extends WithExtSubcommand ? ExtArgs : never);
128
+
129
+ /**
130
+ * Fully-parsed arguments, containing defaults, computed args, and config file values.
131
+ */
132
+ export type ParsedArgs<T = WithServerSubcommand> = CommonArgs<ServerArgs, T>;
133
+
134
+ /**
135
+ * Partial arguments, as supplied by a user. _May_ have defaults applied; _may_ contain config values; _may_ contain computed args.
136
+ */
137
+ export type Args<T = WithServerSubcommand> = CommonArgs<Partial<ServerArgs>, T>;
138
+
139
+ /**
140
+ * Shown by `appium --build-info`
141
+ */
142
+ export type BuildInfo = {
143
+ version: string;
144
+ 'git-sha'?: string;
145
+ built?: string;
146
+ };
@@ -0,0 +1,64 @@
1
+ /**
2
+ * These types describe information about external extensions and the contents of their `package.json` files
3
+ */
4
+
5
+ import type {SchemaObject} from 'ajv';
6
+ import type {PackageJson, SetRequired} from 'type-fest';
7
+ import {DriverType, ExtensionType, PluginType} from '@appium/types';
8
+
9
+ /**
10
+ * This is what is allowed in the `appium.schema` prop of an extension's `package.json`.
11
+ */
12
+ export type ExtSchemaMetadata = string | (SchemaObject & {[key: number]: never});
13
+
14
+ /**
15
+ * Manifest data shared by all extensions, as contained in `package.json`
16
+ */
17
+ export interface CommonExtMetadata {
18
+ mainClass: string;
19
+ scripts?: Record<string, string>;
20
+ schema?: ExtSchemaMetadata;
21
+ }
22
+
23
+ /**
24
+ * Driver-specific manifest data as contained in `package.json`
25
+ */
26
+ export interface DriverMetadata {
27
+ automationName: string;
28
+ platformNames: string[];
29
+ driverName: string;
30
+ }
31
+
32
+ /**
33
+ * Plugin-specific manifest data as stored in `package.json`
34
+ */
35
+ export interface PluginMetadata {
36
+ pluginName: string;
37
+ }
38
+
39
+ /**
40
+ * Generic type to refer to either {@linkcode DriverMetadata} or {@linkcode PluginMetadata}
41
+ * Corresponds to the `appium` prop in an extension's `package.json`.
42
+ */
43
+ export type ExtMetadata<ExtType extends ExtensionType> = (ExtType extends DriverType
44
+ ? DriverMetadata
45
+ : ExtType extends PluginType
46
+ ? PluginMetadata
47
+ : never) &
48
+ CommonExtMetadata;
49
+
50
+ /**
51
+ * A `package.json` containing extension metadata.
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
57
+ */
58
+ export type ExtPackageJson<ExtType extends ExtensionType> = SetRequired<
59
+ PackageJson,
60
+ 'name' | 'version'
61
+ > & {
62
+ appium: ExtMetadata<ExtType>;
63
+ peerDependencies: {appium: string; [key: string]: string};
64
+ };
package/types/index.ts ADDED
@@ -0,0 +1,21 @@
1
+ import {ExtensionType, DriverType, DriverClass, PluginType, PluginClass} from '@appium/types';
2
+
3
+ export * from './appium-manifest';
4
+ export * from './extension-manifest';
5
+ export * from './cli';
6
+
7
+ /**
8
+ * Known environment variables concerning Appium
9
+ */
10
+ export interface AppiumEnv extends NodeJS.ProcessEnv {
11
+ APPIUM_HOME?: string;
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;