appium 2.0.0-beta.30 → 2.0.0-beta.33

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 (36) hide show
  1. package/build/lib/appium.d.ts +1 -1
  2. package/build/lib/appium.d.ts.map +1 -1
  3. package/build/lib/appium.js +5 -2
  4. package/build/lib/cli/parser.d.ts +3 -2
  5. package/build/lib/cli/parser.d.ts.map +1 -1
  6. package/build/lib/cli/parser.js +1 -1
  7. package/build/lib/config.d.ts +5 -4
  8. package/build/lib/config.d.ts.map +1 -1
  9. package/build/lib/config.js +1 -1
  10. package/build/lib/extension/manifest.d.ts.map +1 -1
  11. package/build/lib/extension/manifest.js +1 -1
  12. package/build/lib/main.d.ts +13 -10
  13. package/build/lib/main.d.ts.map +1 -1
  14. package/build/lib/main.js +57 -50
  15. package/build/tsconfig.tsbuildinfo +1 -1
  16. package/build/types/appium-manifest.d.ts +40 -0
  17. package/build/types/appium-manifest.d.ts.map +1 -0
  18. package/build/types/cli.d.ts +112 -0
  19. package/build/types/cli.d.ts.map +1 -0
  20. package/build/types/extension.d.ts +43 -0
  21. package/build/types/extension.d.ts.map +1 -0
  22. package/build/types/external-manifest.d.ts +47 -0
  23. package/build/types/external-manifest.d.ts.map +1 -0
  24. package/build/types/index.d.ts +15 -0
  25. package/build/types/index.d.ts.map +1 -0
  26. package/lib/appium.js +7 -3
  27. package/lib/cli/parser.js +2 -1
  28. package/lib/config.js +6 -5
  29. package/lib/extension/manifest.js +0 -2
  30. package/lib/main.js +78 -63
  31. package/package.json +18 -12
  32. package/types/{appium-manifest.d.ts → appium-manifest.ts} +1 -1
  33. package/types/{cli.d.ts → cli.ts} +48 -29
  34. package/types/{extension.d.ts → extension.ts} +4 -4
  35. package/types/{external-manifest.d.ts → external-manifest.ts} +2 -2
  36. package/types/{index.d.ts → index.ts} +7 -0
@@ -0,0 +1,112 @@
1
+ import { ServerArgs } from '@appium/types';
2
+ import type { DRIVER_TYPE as DRIVER_SUBCOMMAND, EXT_SUBCOMMAND_INSTALL, EXT_SUBCOMMAND_LIST, EXT_SUBCOMMAND_RUN, EXT_SUBCOMMAND_UNINSTALL, EXT_SUBCOMMAND_UPDATE, PLUGIN_TYPE as PLUGIN_SUBCOMMAND, SERVER_SUBCOMMAND } from '../lib/constants';
3
+ export declare type ServerSubcommand = typeof SERVER_SUBCOMMAND;
4
+ export declare type DriverSubcommand = typeof DRIVER_SUBCOMMAND;
5
+ export declare type PluginSubcommand = typeof PLUGIN_SUBCOMMAND;
6
+ /**
7
+ * Possible subcommands for the `appium` CLI.
8
+ */
9
+ export declare type CliSubcommand = ServerSubcommand | DriverSubcommand | PluginSubcommand;
10
+ /**
11
+ * Possible subcommands of {@linkcode DriverSubcommand} or
12
+ * {@linkcode PluginSubcommand}.
13
+ */
14
+ export declare type CliExtensionSubcommand = typeof EXT_SUBCOMMAND_INSTALL | typeof EXT_SUBCOMMAND_LIST | typeof EXT_SUBCOMMAND_RUN | typeof EXT_SUBCOMMAND_UPDATE | typeof EXT_SUBCOMMAND_UNINSTALL;
15
+ /**
16
+ * Random stuff that may appear in the parsed args which has no equivalent in a
17
+ * config file.
18
+ */
19
+ export interface MoreArgs {
20
+ /**
21
+ * Possible subcommands. If empty, defaults to {@linkcode ServerSubcommand}.
22
+ */
23
+ subcommand?: CliSubcommand;
24
+ /**
25
+ * Path to config file, if any. Does not make sense for this to be allowed in a config file!
26
+ */
27
+ configFile?: string;
28
+ /**
29
+ * If true, show the config and exit
30
+ */
31
+ showConfig?: boolean;
32
+ /**
33
+ * If true, open a REPL
34
+ */
35
+ shell?: boolean;
36
+ }
37
+ /**
38
+ * These arguments are _not_ supported by the CLI, but only via programmatic usage / tests.
39
+ */
40
+ export interface ProgrammaticArgs {
41
+ /**
42
+ * If `true`, throw on error instead of exit.
43
+ */
44
+ throwInsteadOfExit?: boolean;
45
+ /**
46
+ * Seems to only be used in tests or standalone driver calls
47
+ */
48
+ logHandler?: (...args: any[]) => void;
49
+ /**
50
+ * Alternate way to set `APPIUM_HOME` for tests. Since we don't want to muck about
51
+ * with the environment, we just set it here.
52
+ *
53
+ * Setting this means that any discovery of the proper `APPIUM_HOME` path is bypassed
54
+ * and is equivalent to setting `APPIUM_HOME` in the environment.
55
+ */
56
+ appiumHome?: string;
57
+ /**
58
+ * If true, show the {@link BuildInfo build info} and exit
59
+ */
60
+ showBuildInfo?: boolean;
61
+ /**
62
+ * If true, show config and exit
63
+ */
64
+ showConfig?: boolean;
65
+ }
66
+ /**
67
+ * These are args which the user will specify if using an extension command
68
+ */
69
+ export interface ExtArgs extends WithExtSubcommand {
70
+ /**
71
+ * Subcommands of `driver` subcommand
72
+ */
73
+ driverCommand?: CliExtensionSubcommand;
74
+ /**
75
+ * Subcommands of `plugin` subcommand
76
+ */
77
+ pluginCommand?: CliExtensionSubcommand;
78
+ }
79
+ /**
80
+ * Args having the `server` subcommand
81
+ */
82
+ export interface WithServerSubcommand {
83
+ subcommand?: ServerSubcommand;
84
+ }
85
+ /**
86
+ * Args having the `driver` or `plugin` subcommand
87
+ */
88
+ export interface WithExtSubcommand {
89
+ subcommand: DriverSubcommand | PluginSubcommand;
90
+ }
91
+ /**
92
+ * Some generic bits of arguments; should not be used outside this declaration
93
+ */
94
+ declare type CommonArgs<SArgs, T = WithServerSubcommand> = MoreArgs & ProgrammaticArgs & (T extends WithServerSubcommand ? SArgs : T extends WithExtSubcommand ? ExtArgs : never);
95
+ /**
96
+ * Fully-parsed arguments, containing defaults, computed args, and config file values.
97
+ */
98
+ export declare type ParsedArgs<T = WithServerSubcommand> = CommonArgs<ServerArgs, T>;
99
+ /**
100
+ * Partial arguments, as supplied by a user. _May_ have defaults applied; _may_ contain config values; _may_ contain computed args.
101
+ */
102
+ export declare type Args<T = WithServerSubcommand> = CommonArgs<Partial<ServerArgs>, T>;
103
+ /**
104
+ * Shown by `appium --build-info`
105
+ */
106
+ export declare type BuildInfo = {
107
+ version: string;
108
+ 'git-sha'?: string;
109
+ built?: string;
110
+ };
111
+ export {};
112
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../types/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EACV,WAAW,IAAI,iBAAiB,EAChC,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,WAAW,IAAI,iBAAiB,EAChC,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAE1B,oBAAY,gBAAgB,GAAG,OAAO,iBAAiB,CAAC;AACxD,oBAAY,gBAAgB,GAAG,OAAO,iBAAiB,CAAC;AACxD,oBAAY,gBAAgB,GAAG,OAAO,iBAAiB,CAAC;AAExD;;GAEG;AACH,oBAAY,aAAa,GACrB,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,CAAC;AAErB;;;GAGG;AACH,oBAAY,sBAAsB,GAC9B,OAAO,sBAAsB,GAC7B,OAAO,mBAAmB,GAC1B,OAAO,kBAAkB,GACzB,OAAO,qBAAqB,GAC5B,OAAO,wBAAwB,CAAC;AAEpC;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC;IAE3B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;IAEtC;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,OAAQ,SAAQ,iBAAiB;IAChD;;OAEG;IACH,aAAa,CAAC,EAAE,sBAAsB,CAAC;IAEvC;;OAEG;IACH,aAAa,CAAC,EAAE,sBAAsB,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,gBAAgB,GAAG,gBAAgB,CAAC;CACjD;AAED;;GAEG;AACH,aAAK,UAAU,CAAC,KAAK,EAAE,CAAC,GAAG,oBAAoB,IAAI,QAAQ,GACzD,gBAAgB,GAChB,CAAC,CAAC,SAAS,oBAAoB,GAC3B,KAAK,GACL,CAAC,SAAS,iBAAiB,GAC3B,OAAO,GACP,KAAK,CAAC,CAAC;AAEb;;GAEG;AACH,oBAAY,UAAU,CAAC,CAAC,GAAG,oBAAoB,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;AAE7E;;GAEG;AACH,oBAAY,IAAI,CAAC,CAAC,GAAG,oBAAoB,IAAI,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;AAEhF;;GAEG;AACH,oBAAY,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
@@ -0,0 +1,43 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * These types describe information about external extensions and the contents of their `package.json` files
3
+ */
4
+ import type { SchemaObject } from 'ajv';
5
+ import type { PackageJson, SetRequired } from 'type-fest';
6
+ import { DriverType, ExtensionType, PluginType } from './index';
7
+ /**
8
+ * This is what is allowed in the `appium.schema` prop of an extension's `package.json`.
9
+ */
10
+ export declare type SchemaMetadata = string | (SchemaObject & {
11
+ [key: number]: never;
12
+ });
13
+ /**
14
+ * Manifest data shared by all extensions, as contained in `package.json`
15
+ */
16
+ export interface CommonMetadata {
17
+ mainClass: string;
18
+ scripts?: Record<string, string>;
19
+ schema?: SchemaMetadata;
20
+ }
21
+ /**
22
+ * Driver-specific manifest data as contained in `package.json`
23
+ */
24
+ export interface DriverMetadata {
25
+ automationName: string;
26
+ platformNames: string[];
27
+ driverName: string;
28
+ }
29
+ /**
30
+ * Plugin-specific manifest data as stored in `package.json`
31
+ */
32
+ export interface PluginMetadata {
33
+ pluginName: string;
34
+ }
35
+ /**
36
+ * Generic type to refer to either {@linkcode DriverMetadata} or {@linkcode PluginMetadata}
37
+ * Corresponds to the `appium` prop in an extension's `package.json`.
38
+ */
39
+ export declare type ExtMetadata<ExtType extends ExtensionType> = (ExtType extends DriverType ? DriverMetadata : ExtType extends PluginType ? PluginMetadata : never) & CommonMetadata;
40
+ /**
41
+ * A `package.json` containing extension metadata.
42
+ * Required fields are `name`, `version`, and `appium`.
43
+ */
44
+ export declare type ExtPackageJson<ExtType extends ExtensionType> = SetRequired<PackageJson, 'name' | 'version'> & {
45
+ appium: ExtMetadata<ExtType>;
46
+ };
47
+ //# sourceMappingURL=external-manifest.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,15 @@
1
+ /// <reference types="node" />
2
+ export * from './appium-manifest';
3
+ export * from './external-manifest';
4
+ export * from './extension';
5
+ export * from './cli';
6
+ export declare type DriverType = 'driver';
7
+ export declare type PluginType = 'plugin';
8
+ export declare type ExtensionType = DriverType | PluginType;
9
+ /**
10
+ * Known environment variables concerning Appium
11
+ */
12
+ export interface AppiumEnv extends NodeJS.ProcessEnv {
13
+ APPIUM_HOME?: string;
14
+ }
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../types/index.ts"],"names":[],"mappings":";AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,oBAAY,UAAU,GAAG,QAAQ,CAAC;AAClC,oBAAY,UAAU,GAAG,QAAQ,CAAC;AAClC,oBAAY,aAAa,GAAG,UAAU,GAAG,UAAU,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,SAAU,SAAQ,MAAM,CAAC,UAAU;IAClD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
package/lib/appium.js CHANGED
@@ -274,10 +274,14 @@ class AppiumDriver extends DriverCore {
274
274
  // the driver so that they cannot be mimicked by a malicious user sending in capabilities
275
275
  this.assignCliArgsToExtension('driver', driverName, driverInstance);
276
276
 
277
-
278
277
  // This assignment is required for correct web sockets functionality inside the driver
279
278
  // Drivers/plugins might also want to know where they are hosted
280
- driverInstance.assignServer(this.server, this.args.address, this.args.port, this.args.basePath);
279
+
280
+ // XXX: temporary hack to work around #16747
281
+ driverInstance.server = this.server;
282
+ driverInstance.serverHost = this.args.address;
283
+ driverInstance.serverPort = this.args.port;
284
+ driverInstance.serverPath = this.args.basePath;
281
285
 
282
286
  try {
283
287
  runningDriversData = await this.curSessionDataForDriver(InnerDriver) ?? [];
@@ -737,7 +741,7 @@ export { AppiumDriver };
737
741
  * @typedef {import('@appium/types').ExternalDriver} ExternalDriver
738
742
  * @typedef {import('@appium/types').W3CCapabilities} W3CCapabilities
739
743
  * @typedef {import('@appium/types').DriverData} DriverData
740
- * @typedef {import('@appium/types').DriverOpts} DriverOpts
744
+ * @typedef {import('@appium/types').ServerArgs} DriverOpts
741
745
  * @typedef {import('@appium/types').Constraints} Constraints
742
746
  * @typedef {import('@appium/types').AppiumServer} AppiumServer
743
747
  * @typedef {import('../types').ExtensionType} ExtensionType
package/lib/cli/parser.js CHANGED
@@ -99,8 +99,9 @@ class ArgParser {
99
99
  * If no subcommand is passed in, this method will inject the `server` subcommand.
100
100
  *
101
101
  * `ArgParser.prototype.parse_args` is an alias of this method.
102
+ * @template [T=import('../../types').WithServerSubcommand]
102
103
  * @param {string[]} [args] - Array of arguments, ostensibly from `process.argv`. Gathers args from `process.argv` if not provided.
103
- * @returns {import('../../types/cli').ParsedArgs} - The parsed arguments
104
+ * @returns {import('../../types').Args<T>} - The parsed arguments
104
105
  */
105
106
  parseArgs (args = process.argv.slice(2)) {
106
107
  if (!NON_SERVER_ARGS.has(args[0])) {
package/lib/config.js CHANGED
@@ -160,14 +160,14 @@ async function showBuildInfo () {
160
160
 
161
161
  /**
162
162
  * Returns k/v pairs of server arguments which are _not_ the defaults.
163
- * @param {ParsedArgs} parsedArgs
164
- * @returns {Partial<ParsedArgs>}
163
+ * @param {Args} parsedArgs
164
+ * @returns {Args}
165
165
  */
166
166
  function getNonDefaultServerArgs (parsedArgs) {
167
167
  /**
168
168
  * Flattens parsed args into a single level object for comparison with
169
169
  * flattened defaults across server args and extension args.
170
- * @param {ParsedArgs} args
170
+ * @param {Args} args
171
171
  * @returns {Record<string, { value: any, argSpec: ArgSpec }>}
172
172
  */
173
173
  const flatten = (args) => {
@@ -237,7 +237,7 @@ function getNonDefaultServerArgs (parsedArgs) {
237
237
  return _.reduce(
238
238
  _.pickBy(args, (__, key) => isNotDefault(key)),
239
239
  // explodes the flattened object back into nested one
240
- (acc, {value, argSpec}) => _.set(acc, argSpec.dest, value), /** @type {Partial<ParsedArgs>} */({})
240
+ (acc, {value, argSpec}) => _.set(acc, argSpec.dest, value), /** @type {Args} */({})
241
241
  );
242
242
  }
243
243
 
@@ -306,7 +306,8 @@ export {
306
306
  };
307
307
 
308
308
  /**
309
- * @typedef {import('../types/cli').ParsedArgs} ParsedArgs
309
+ * @typedef {import('../types').ParsedArgs} ParsedArgs
310
+ * @typedef {import('../types').Args} Args
310
311
  * @typedef {import('./schema/arg-spec').ArgSpec} ArgSpec
311
312
  */
312
313
 
@@ -1,5 +1,3 @@
1
- /// <reference path="../../types/appium-manifest.d.ts" />
2
-
3
1
  /**
4
2
  * Module containing {@link Manifest} which handles reading & writing of extension config files.
5
3
  */
package/lib/main.js CHANGED
@@ -54,13 +54,16 @@ async function preflightChecks (args, throwInsteadOfExit = false) {
54
54
  }
55
55
 
56
56
  /**
57
- * @param {Partial<ParsedArgs>} args
57
+ * @param {Args} args
58
58
  */
59
59
  function logNonDefaultArgsWarning (args) {
60
60
  logger.info('Non-default server args:');
61
61
  inspect(args);
62
62
  }
63
63
 
64
+ /**
65
+ * @param {Args['defaultCapabilities']} caps
66
+ */
64
67
  function logDefaultCapabilitiesWarning (caps) {
65
68
  logger.info('Default capabilities, which will be added to each request ' +
66
69
  'unless overridden by desired capabilities:');
@@ -122,11 +125,20 @@ function getServerUpdaters (driverClasses, pluginClasses) {
122
125
  */
123
126
  function getExtraMethodMap (driverClasses, pluginClasses) {
124
127
  return [...driverClasses, ...pluginClasses].reduce(
125
- (map, klass) => ({...map, ...klass.newMethodMap}),
128
+ (map, klass) => ({...map, .../** @type {DriverClass} */(klass).newMethodMap ?? {}}),
126
129
  {}
127
130
  );
128
131
  }
129
132
 
133
+ /**
134
+ * @template [T=WithServerSubcommand]
135
+ * @param {Args<T>} args
136
+ * @returns {args is Args<WithServerSubcommand>}
137
+ */
138
+ function areServerCommandArgs (args) {
139
+ return args.subcommand === SERVER_SUBCOMMAND;
140
+ }
141
+
130
142
  /**
131
143
  * Initializes Appium, but does not start the server.
132
144
  *
@@ -134,7 +146,8 @@ function getExtraMethodMap (driverClasses, pluginClasses) {
134
146
  *
135
147
  * If `args` contains a non-empty `subcommand` which is not `server`, this function will return an empty object.
136
148
  *
137
- * @param {PartialArgs} [args] - Partial args (progammatic usage only)
149
+ * @template [T=WithServerSubcommand]
150
+ * @param {Args<T>} [args] - Partial args (progammatic usage only)
138
151
  * @returns {Promise<ServerInitResult | ExtCommandInitResult>}
139
152
  * @example
140
153
  * import {init, getSchema} from 'appium';
@@ -149,16 +162,9 @@ async function init (args) {
149
162
 
150
163
  const parser = getParser();
151
164
  let throwInsteadOfExit = false;
152
- /** @type {ParsedArgs} */
153
- let preConfigParsedArgs;
154
- /** @type {ParsedArgs} */
155
- let parsedArgs;
156
- /**
157
- * This is a definition (instead of declaration) because TS can't figure out
158
- * the value will be defined when it's used.
159
- * @type {ReturnType<getDefaultsForSchema>}
160
- */
161
- let defaults = {};
165
+ /** @type {Args<T>} */
166
+ let preConfigArgs;
167
+
162
168
  if (args) {
163
169
  // if we have a containing package instead of running as a CLI process,
164
170
  // that package might not appreciate us calling 'process.exit' willy-
@@ -168,13 +174,13 @@ async function init (args) {
168
174
  // but remove it since it's not a real server arg per se
169
175
  delete args.throwInsteadOfExit;
170
176
  }
171
- preConfigParsedArgs = /** @type {ParsedArgs} */({...args, subcommand: args.subcommand ?? SERVER_SUBCOMMAND});
177
+ preConfigArgs = {...args, subcommand: args.subcommand ?? SERVER_SUBCOMMAND};
172
178
  } else {
173
179
  // otherwise parse from CLI
174
- preConfigParsedArgs = parser.parseArgs();
180
+ preConfigArgs = /** @type {Args<T>} */(parser.parseArgs());
175
181
  }
176
182
 
177
- const configResult = await readConfigFile(preConfigParsedArgs.configFile);
183
+ const configResult = await readConfigFile(preConfigArgs.configFile);
178
184
 
179
185
  if (!_.isEmpty(configResult.errors)) {
180
186
  throw new Error(`Errors in config file ${configResult.filepath}:\n ${configResult.reason ?? configResult.errors}`);
@@ -185,63 +191,65 @@ async function init (args) {
185
191
  // 1. command line args
186
192
  // 2. config file
187
193
  // 3. defaults from config file.
188
- if (preConfigParsedArgs.subcommand === SERVER_SUBCOMMAND) {
189
- defaults = getDefaultsForSchema(false);
194
+ if (!areServerCommandArgs(preConfigArgs)) {
190
195
 
191
- parsedArgs = _.defaultsDeep(
192
- preConfigParsedArgs,
196
+ // if the user has requested the 'driver' CLI, don't run the normal server,
197
+ // but instead pass control to the driver CLI
198
+ if (preConfigArgs.subcommand === DRIVER_TYPE) {
199
+ await runExtensionCommand(preConfigArgs, driverConfig);
200
+ return {};
201
+ }
202
+ if (preConfigArgs.subcommand === PLUGIN_TYPE) {
203
+ await runExtensionCommand(preConfigArgs, pluginConfig);
204
+ return {};
205
+ }
206
+ /* istanbul ignore next */
207
+ return {}; // should never happen
208
+ } else {
209
+ const defaults = getDefaultsForSchema(false);
210
+
211
+ /** @type {ParsedArgs} */
212
+ const serverArgs = _.defaultsDeep(
213
+ preConfigArgs,
193
214
  configResult.config?.server,
194
215
  defaults
195
216
  );
196
217
 
197
- if (preConfigParsedArgs.showConfig) {
198
- showConfig(getNonDefaultServerArgs(preConfigParsedArgs), configResult, defaults, parsedArgs);
218
+ if (preConfigArgs.showConfig) {
219
+ showConfig(getNonDefaultServerArgs(preConfigArgs), configResult, defaults, serverArgs);
199
220
  return {};
200
221
  }
201
222
 
202
- } else {
203
- parsedArgs = preConfigParsedArgs;
204
- }
205
-
206
- await logsinkInit(parsedArgs);
207
-
208
- // if the user has requested the 'driver' CLI, don't run the normal server,
209
- // but instead pass control to the driver CLI
210
- if (parsedArgs.subcommand === DRIVER_TYPE) {
211
- await runExtensionCommand(parsedArgs, driverConfig);
212
- return {};
213
- }
214
- if (parsedArgs.subcommand === PLUGIN_TYPE) {
215
- await runExtensionCommand(parsedArgs, pluginConfig);
216
- return {};
217
- }
223
+ await logsinkInit(serverArgs);
218
224
 
219
- if (parsedArgs.logFilters) {
220
- const {issues, rules} = await logFactory.loadSecureValuesPreprocessingRules(parsedArgs.logFilters);
221
- if (!_.isEmpty(issues)) {
222
- throw new Error(`The log filtering rules config '${parsedArgs.logFilters}' has issues: ` +
225
+ if (serverArgs.logFilters) {
226
+ const {issues, rules} = await logFactory.loadSecureValuesPreprocessingRules(serverArgs.logFilters);
227
+ if (!_.isEmpty(issues)) {
228
+ throw new Error(`The log filtering rules config '${serverArgs.logFilters}' has issues: ` +
223
229
  JSON.stringify(issues, null, 2));
230
+ }
231
+ if (_.isEmpty(rules)) {
232
+ logger.warn(`Found no log filtering rules in '${serverArgs.logFilters}'. Is that expected?`);
233
+ } else {
234
+ logger.info(`Loaded ${util.pluralize('filtering rule', rules.length, true)} from '${serverArgs.logFilters}'`);
235
+ }
224
236
  }
225
- if (_.isEmpty(rules)) {
226
- logger.warn(`Found no log filtering rules in '${parsedArgs.logFilters}'. Is that expected?`);
227
- } else {
228
- logger.info(`Loaded ${util.pluralize('filtering rule', rules.length, true)} from '${parsedArgs.logFilters}'`);
229
- }
230
- }
231
237
 
232
- const appiumDriver = new AppiumDriver(parsedArgs);
233
- // set the config on the umbrella driver so it can match drivers to caps
234
- appiumDriver.driverConfig = driverConfig;
235
- await preflightChecks(parsedArgs, throwInsteadOfExit);
238
+ const appiumDriver = new AppiumDriver(serverArgs);
239
+ // set the config on the umbrella driver so it can match drivers to caps
240
+ appiumDriver.driverConfig = driverConfig;
241
+ await preflightChecks(serverArgs, throwInsteadOfExit);
236
242
 
237
- return /** @type {ServerInitResult} */({appiumDriver, parsedArgs, driverConfig, pluginConfig});
243
+ return /** @type {ServerInitResult} */({appiumDriver, parsedArgs: serverArgs, driverConfig, pluginConfig});
244
+ }
238
245
  }
239
246
 
240
247
  /**
241
248
  * Initializes Appium's config. Starts server if appropriate and resolves the
242
249
  * server instance if so; otherwise resolves w/ `undefined`.
243
- * @param {PartialArgs} [args] - Arguments from CLI or otherwise
244
- * @returns {Promise<import('http').Server|undefined>}
250
+ * @template [T=WithServerSubcommand]
251
+ * @param {Args<T>} [args] - Arguments from CLI or otherwise
252
+ * @returns {Promise<import('@appium/types').AppiumServer|undefined>}
245
253
  */
246
254
  async function main (args) {
247
255
  const {appiumDriver, parsedArgs, pluginConfig, driverConfig} = /** @type {ServerInitResult} */(await init(args));
@@ -339,15 +347,11 @@ export { finalizeSchema, getSchema, validate } from './schema/schema';
339
347
  export { main, init, resolveAppiumHome };
340
348
 
341
349
  /**
342
- * @typedef {import('../types/cli').ParsedArgs} ParsedArgs
343
- */
344
-
345
- /**
346
- * @typedef {import('../types/cli').PartialArgs} PartialArgs
347
350
  * @typedef {import('../types').DriverType} DriverType
348
351
  * @typedef {import('../types').PluginType} PluginType
349
- * @typedef {import('../types/extension').DriverClass} DriverClass
350
- * @typedef {import('../types/extension').PluginClass} PluginClass
352
+ * @typedef {import('../types').DriverClass} DriverClass
353
+ * @typedef {import('../types').PluginClass} PluginClass
354
+ * @typedef {import('../types').WithServerSubcommand} WithServerSubcommand
351
355
  */
352
356
 
353
357
  /**
@@ -358,9 +362,20 @@ export { main, init, resolveAppiumHome };
358
362
  /**
359
363
  * @typedef ServerInitData
360
364
  * @property {AppiumDriver} appiumDriver - The Appium driver
361
- * @property {ParsedArgs} parsedArgs - The parsed arguments
365
+ * @property {import('../types').ParsedArgs} parsedArgs - The parsed arguments
362
366
  */
363
367
 
364
368
  /**
365
369
  * @typedef {ServerInitData & import('./extension').ExtensionConfigs} ServerInitResult
366
370
  */
371
+
372
+ /**
373
+ * @template [T=WithServerSubcommand]
374
+ * @typedef {import('../types').Args<T>} Args
375
+ */
376
+
377
+ /**
378
+ * @template [T=WithServerSubcommand]
379
+ * @typedef {import('../types').ParsedArgs<T>} ParsedArgs
380
+ */
381
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium",
3
- "version": "2.0.0-beta.30",
3
+ "version": "2.0.0-beta.33",
4
4
  "description": "Automation for Apps.",
5
5
  "keywords": [
6
6
  "automation",
@@ -40,18 +40,24 @@
40
40
  "build": "babel lib --root-mode=upward --out-dir=build/lib",
41
41
  "dev": "npm run build -- --watch",
42
42
  "fix": "npm run lint -- --fix",
43
- "generate-docs": "node ./scripts/parse-yml-commands.js",
43
+ "build:docs": "node docs/scripts/build-docs.js",
44
+ "build:docs:assets": "node docs/scripts/copy-assets.js",
45
+ "dev:docs": "npm run build:docs:assets && npm run dev:docs:en",
46
+ "dev:docs:en": "mkdocs serve -f ./docs/mkdocs-en.yml",
47
+ "dev:docs:ja": "mkdocs serve -f ./docs/mkdocs-ja.yml",
48
+ "publish:docs": "APPIUM_DOCS_PUBLISH=1 npm run build:docs",
44
49
  "postinstall": "node ./scripts/postinstall.js",
45
50
  "lint": "eslint -c ../../.eslintrc --ignore-path ../../.eslintignore .",
46
51
  "test": "npm run test:unit",
47
- "test:e2e": "mocha --require ../../test/setup-babel.js --timeout 20s --slow 10s \"./test/e2e/**/*.spec.js\"",
48
- "test:unit": "mocha --require ../../test/setup-babel.js \"./test/unit/**/*.spec.js\""
52
+ "test:e2e": "mocha --timeout 30s --slow 15s \"./test/e2e/**/*.spec.js\"",
53
+ "test:unit": "mocha \"./test/unit/**/*.spec.js\""
49
54
  },
50
55
  "dependencies": {
51
- "@appium/base-driver": "^8.4.2",
52
- "@appium/base-plugin": "1.8.1",
53
- "@appium/schema": "^0.0.2",
54
- "@appium/support": "^2.57.1",
56
+ "@appium/base-driver": "^8.5.2",
57
+ "@appium/base-plugin": "^1.8.4",
58
+ "@appium/docutils": "^0.0.3",
59
+ "@appium/schema": "^0.0.5",
60
+ "@appium/support": "^2.57.4",
55
61
  "@babel/runtime": "7.17.9",
56
62
  "@sidvind/better-ajv-errors": "1.1.1",
57
63
  "ajv": "8.11.0",
@@ -69,12 +75,12 @@
69
75
  "ora": "5.4.1",
70
76
  "package-changed": "1.9.0",
71
77
  "resolve-from": "5.0.0",
72
- "semver": "7.3.6",
78
+ "semver": "7.3.7",
73
79
  "source-map-support": "0.5.21",
74
80
  "teen_process": "1.16.0",
75
81
  "winston": "3.7.2",
76
82
  "word-wrap": "1.2.3",
77
- "yaml": "1.10.2"
83
+ "yaml": "2.0.1"
78
84
  },
79
85
  "engines": {
80
86
  "node": ">=12",
@@ -84,6 +90,6 @@
84
90
  "access": "public",
85
91
  "tag": "next"
86
92
  },
87
- "types": "./build/lib/index.d.ts",
88
- "gitHead": "319f7289e7019efaeac1271936b2d991041a02c2"
93
+ "types": "./build/lib/main.d.ts",
94
+ "gitHead": "f15f11bc14d777185ed908a7840657b089cb1049"
89
95
  }
@@ -28,7 +28,7 @@ export type ExtManifest<ExtType extends ExtensionType> = Omit<
28
28
  InternalMetadata &
29
29
  CommonMetadata; // XXX: ExtMetadata should be a union with CommonMetadata. why is this needed?
30
30
 
31
- type WithSchemaManifest = {
31
+ export type WithSchemaManifest = {
32
32
  schema: SchemaMetadata;
33
33
  };
34
34