appium 2.0.0-beta.30 → 2.0.0-beta.35

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 (69) 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/args.js +1 -1
  5. package/build/lib/cli/driver-command.d.ts +3 -3
  6. package/build/lib/cli/driver-command.d.ts.map +1 -1
  7. package/build/lib/cli/driver-command.js +8 -8
  8. package/build/lib/cli/extension-command.d.ts +22 -17
  9. package/build/lib/cli/extension-command.d.ts.map +1 -1
  10. package/build/lib/cli/extension-command.js +35 -36
  11. package/build/lib/cli/extension.js +1 -1
  12. package/build/lib/cli/parser.d.ts +3 -2
  13. package/build/lib/cli/parser.d.ts.map +1 -1
  14. package/build/lib/cli/parser.js +1 -1
  15. package/build/lib/cli/plugin-command.d.ts +9 -15
  16. package/build/lib/cli/plugin-command.d.ts.map +1 -1
  17. package/build/lib/cli/plugin-command.js +8 -8
  18. package/build/lib/cli/utils.js +1 -1
  19. package/build/lib/config-file.js +1 -1
  20. package/build/lib/config.d.ts +5 -4
  21. package/build/lib/config.d.ts.map +1 -1
  22. package/build/lib/config.js +1 -1
  23. package/build/lib/constants.js +1 -1
  24. package/build/lib/extension/driver-config.js +1 -1
  25. package/build/lib/extension/extension-config.js +1 -1
  26. package/build/lib/extension/index.js +1 -1
  27. package/build/lib/extension/manifest.d.ts.map +1 -1
  28. package/build/lib/extension/manifest.js +1 -1
  29. package/build/lib/extension/package-changed.js +1 -1
  30. package/build/lib/extension/plugin-config.js +1 -1
  31. package/build/lib/grid-register.js +1 -1
  32. package/build/lib/logger.js +1 -1
  33. package/build/lib/logsink.js +1 -1
  34. package/build/lib/main.d.ts +13 -10
  35. package/build/lib/main.d.ts.map +1 -1
  36. package/build/lib/main.js +57 -50
  37. package/build/lib/schema/arg-spec.js +1 -1
  38. package/build/lib/schema/cli-args.js +1 -1
  39. package/build/lib/schema/cli-transformers.js +1 -1
  40. package/build/lib/schema/index.js +1 -1
  41. package/build/lib/schema/keywords.js +1 -1
  42. package/build/lib/schema/schema.js +1 -1
  43. package/build/lib/utils.js +1 -1
  44. package/build/tsconfig.tsbuildinfo +1 -1
  45. package/build/types/appium-manifest.d.ts +40 -0
  46. package/build/types/appium-manifest.d.ts.map +1 -0
  47. package/build/types/cli.d.ts +112 -0
  48. package/build/types/cli.d.ts.map +1 -0
  49. package/build/types/extension.d.ts +43 -0
  50. package/build/types/extension.d.ts.map +1 -0
  51. package/build/types/external-manifest.d.ts +47 -0
  52. package/build/types/external-manifest.d.ts.map +1 -0
  53. package/build/types/index.d.ts +15 -0
  54. package/build/types/index.d.ts.map +1 -0
  55. package/lib/appium.js +7 -3
  56. package/lib/cli/driver-command.js +45 -20
  57. package/lib/cli/extension-command.js +229 -123
  58. package/lib/cli/parser.js +2 -1
  59. package/lib/cli/plugin-command.js +33 -18
  60. package/lib/config.js +6 -5
  61. package/lib/extension/manifest.js +0 -2
  62. package/lib/main.js +78 -63
  63. package/package.json +20 -14
  64. package/types/{appium-manifest.d.ts → appium-manifest.ts} +1 -1
  65. package/types/{cli.d.ts → cli.ts} +48 -29
  66. package/types/{extension.d.ts → extension.ts} +4 -4
  67. package/types/{external-manifest.d.ts → external-manifest.ts} +2 -2
  68. package/types/{index.d.ts → index.ts} +7 -0
  69. package/lib/appium-config.schema.json +0 -278
@@ -1,14 +1,16 @@
1
1
  import _ from 'lodash';
2
2
  import ExtensionCommand from './extension-command';
3
- import { KNOWN_PLUGINS } from '../constants';
3
+ import {KNOWN_PLUGINS} from '../constants';
4
4
 
5
5
  const REQ_PLUGIN_FIELDS = ['pluginName', 'mainClass'];
6
6
 
7
+ /**
8
+ * @extends {ExtensionCommand<PluginType>}
9
+ */
7
10
  export default class PluginCommand extends ExtensionCommand {
8
-
9
11
  /**
10
12
  *
11
- * @param {PluginCommandOptions} opts
13
+ * @param {import('./extension-command').ExtensionCommandOptions<PluginType>} opts
12
14
  */
13
15
  constructor ({config, json}) {
14
16
  super({config, json});
@@ -16,41 +18,54 @@ export default class PluginCommand extends ExtensionCommand {
16
18
  }
17
19
 
18
20
  async install ({plugin, installType, packageName}) {
19
- return await super._install({ext: plugin, installType, packageName});
21
+ return await super._install({
22
+ installSpec: plugin,
23
+ installType,
24
+ packageName,
25
+ });
20
26
  }
21
27
 
22
28
  async uninstall ({plugin}) {
23
- return await super._uninstall({ext: plugin});
29
+ return await super._uninstall({installSpec: plugin});
24
30
  }
25
31
 
26
32
  async update ({plugin, unsafe}) {
27
- return await super._update({ext: plugin, unsafe});
33
+ return await super._update({installSpec: plugin, unsafe});
28
34
  }
29
35
 
30
36
  async run ({plugin, scriptName}) {
31
- return await super._run({ext: plugin, scriptName});
37
+ return await super._run({installSpec: plugin, scriptName});
32
38
  }
33
39
 
34
40
  getPostInstallText ({extName, extData}) {
35
41
  return `Plugin ${extName}@${extData.version} successfully installed`.green;
36
42
  }
37
43
 
38
- validateExtensionFields (appiumPkgData) {
39
- const missingFields = REQ_PLUGIN_FIELDS.reduce((acc, field) => (
40
- appiumPkgData[field] ? acc : [...acc, field]
41
- ), []);
44
+ /**
45
+ * Validates fields in `appium` field of `driverMetadata`
46
+ *
47
+ * For any `package.json` fields which a driver requires, validate the type of
48
+ * those fields on the `package.json` data, throwing an error if anything is
49
+ * amiss.
50
+ * @param {import('appium/types').ExtMetadata<PluginType>} pluginMetadata
51
+ * @param {string} installSpec
52
+ * @returns {void}
53
+ */
54
+ validateExtensionFields (pluginMetadata, installSpec) {
55
+ const missingFields = REQ_PLUGIN_FIELDS.reduce(
56
+ (acc, field) => (pluginMetadata[field] ? acc : [...acc, field]),
57
+ []
58
+ );
42
59
 
43
60
  if (!_.isEmpty(missingFields)) {
44
- throw new Error(`Installed plugin did not expose correct fields for compability ` +
45
- `with Appium. Missing fields: ${JSON.stringify(missingFields)}`);
61
+ throw new Error(
62
+ `Installed plugin "${installSpec}" did not expose correct fields for compability ` +
63
+ `with Appium. Missing fields: ${JSON.stringify(missingFields)}`
64
+ );
46
65
  }
47
-
48
66
  }
49
-
50
67
  }
51
68
 
52
69
  /**
53
- * @typedef PluginCommandOptions
54
- * @property {import('../extension/extension-config').ExtensionConfig<import('../extension/manifest').PluginType>} config
55
- * @property {boolean} json
70
+ * @typedef {import('appium/types').PluginType} PluginType
56
71
  */
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.35",
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.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",
55
61
  "@babel/runtime": "7.17.9",
56
62
  "@sidvind/better-ajv-errors": "1.1.1",
57
63
  "ajv": "8.11.0",
@@ -59,22 +65,22 @@
59
65
  "argparse": "2.0.1",
60
66
  "async-lock": "1.3.1",
61
67
  "asyncbox": "2.9.2",
62
- "axios": "0.26.1",
68
+ "axios": "0.27.2",
63
69
  "bluebird": "3.7.2",
64
70
  "find-up": "5.0.0",
65
71
  "lilconfig": "2.0.5",
66
72
  "lodash": "4.17.21",
67
73
  "longjohn": "0.2.12",
68
- "npmlog": "6.0.1",
74
+ "npmlog": "6.0.2",
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": "59dd30ba20d04a068d7b710671f273bc3a2298b7"
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
 
@@ -1,5 +1,5 @@
1
- import { DriverOpts } from '@appium/types';
2
- import {
1
+ import {ServerArgs} from '@appium/types';
2
+ import type {
3
3
  DRIVER_TYPE as DRIVER_SUBCOMMAND,
4
4
  EXT_SUBCOMMAND_INSTALL,
5
5
  EXT_SUBCOMMAND_LIST,
@@ -10,17 +10,21 @@ import {
10
10
  SERVER_SUBCOMMAND,
11
11
  } from '../lib/constants';
12
12
 
13
+ export type ServerSubcommand = typeof SERVER_SUBCOMMAND;
14
+ export type DriverSubcommand = typeof DRIVER_SUBCOMMAND;
15
+ export type PluginSubcommand = typeof PLUGIN_SUBCOMMAND;
16
+
13
17
  /**
14
18
  * Possible subcommands for the `appium` CLI.
15
19
  */
16
- type CliSubcommand =
17
- | typeof SERVER_SUBCOMMAND
18
- | typeof DRIVER_SUBCOMMAND
19
- | typeof PLUGIN_SUBCOMMAND;
20
+ export type CliSubcommand =
21
+ | ServerSubcommand
22
+ | DriverSubcommand
23
+ | PluginSubcommand;
20
24
 
21
25
  /**
22
- * Possible subcommands of {@link DRIVER_SUBCOMMAND} or
23
- * {@link PLUGIN_SUBCOMMAND}.
26
+ * Possible subcommands of {@linkcode DriverSubcommand} or
27
+ * {@linkcode PluginSubcommand}.
24
28
  */
25
29
  export type CliExtensionSubcommand =
26
30
  | typeof EXT_SUBCOMMAND_INSTALL
@@ -33,7 +37,12 @@ export type CliExtensionSubcommand =
33
37
  * Random stuff that may appear in the parsed args which has no equivalent in a
34
38
  * config file.
35
39
  */
36
- interface MoreArgs {
40
+ export interface MoreArgs {
41
+ /**
42
+ * Possible subcommands. If empty, defaults to {@linkcode ServerSubcommand}.
43
+ */
44
+ subcommand?: CliSubcommand;
45
+
37
46
  /**
38
47
  * Path to config file, if any. Does not make sense for this to be allowed in a config file!
39
48
  */
@@ -53,7 +62,7 @@ interface MoreArgs {
53
62
  /**
54
63
  * These arguments are _not_ supported by the CLI, but only via programmatic usage / tests.
55
64
  */
56
- interface ProgrammaticArgs {
65
+ export interface ProgrammaticArgs {
57
66
  /**
58
67
  * If `true`, throw on error instead of exit.
59
68
  */
@@ -85,9 +94,9 @@ interface ProgrammaticArgs {
85
94
  }
86
95
 
87
96
  /**
88
- * These are args that Appium assigns while parsing the args.
97
+ * These are args which the user will specify if using an extension command
89
98
  */
90
- interface InternalArgs {
99
+ export interface ExtArgs extends WithExtSubcommand {
91
100
  /**
92
101
  * Subcommands of `driver` subcommand
93
102
  */
@@ -97,32 +106,42 @@ interface InternalArgs {
97
106
  * Subcommands of `plugin` subcommand
98
107
  */
99
108
  pluginCommand?: CliExtensionSubcommand;
109
+ }
100
110
 
101
- /**
102
- * Possible subcommands
103
- */
104
- subcommand: CliSubcommand;
111
+ /**
112
+ * Args having the `server` subcommand
113
+ */
114
+ export interface WithServerSubcommand {
115
+ subcommand?: ServerSubcommand;
105
116
  }
106
117
 
107
118
  /**
108
- * The same as {@link ParsedArgs} but with a nullable `subcommand`.
109
- * This is _not_ the same as `Partial<ParsedArgs>`.
119
+ * Args having the `driver` or `plugin` subcommand
110
120
  */
111
- export type PartialArgs = DriverOpts &
112
- MoreArgs &
113
- ProgrammaticArgs &
114
- Partial<InternalArgs>;
121
+ export interface WithExtSubcommand {
122
+ subcommand: DriverSubcommand | PluginSubcommand;
123
+ }
115
124
 
116
125
  /**
117
- * The Appium configuration as a flattened object, parsed via CLI args _and_ any
118
- * CLI args unsupported by the config file.
119
- * @todo Does not make any assumptions about property names derived from
120
- * extensions.
126
+ * Some generic bits of arguments; should not be used outside this declaration
121
127
  */
122
- export type ParsedArgs = DriverOpts &
123
- MoreArgs &
128
+ type CommonArgs<SArgs, T = WithServerSubcommand> = MoreArgs &
124
129
  ProgrammaticArgs &
125
- InternalArgs;
130
+ (T extends WithServerSubcommand
131
+ ? SArgs
132
+ : T extends WithExtSubcommand
133
+ ? ExtArgs
134
+ : never);
135
+
136
+ /**
137
+ * Fully-parsed arguments, containing defaults, computed args, and config file values.
138
+ */
139
+ export type ParsedArgs<T = WithServerSubcommand> = CommonArgs<ServerArgs, T>;
140
+
141
+ /**
142
+ * Partial arguments, as supplied by a user. _May_ have defaults applied; _may_ contain config values; _may_ contain computed args.
143
+ */
144
+ export type Args<T = WithServerSubcommand> = CommonArgs<Partial<ServerArgs>, T>;
126
145
 
127
146
  /**
128
147
  * Shown by `appium --build-info`
@@ -1,4 +1,4 @@
1
- import { BaseDriverBase } from '@appium/base-driver/lib/basedriver/driver';
1
+ import type { BaseDriverBase } from '@appium/base-driver/lib/basedriver/driver';
2
2
  import { Class, Driver, ExternalDriver } from '@appium/types';
3
3
  import { DriverType, ExtensionType, PluginType } from '.';
4
4
 
@@ -8,7 +8,7 @@ export type DriverClass = BaseDriverBase<ExternalDriver,
8
8
  /**
9
9
  * Additional static props for external driver classes
10
10
  */
11
- interface ExternalDriverStatic {
11
+ export interface ExternalDriverStatic {
12
12
  driverName: string;
13
13
  }
14
14
 
@@ -20,7 +20,7 @@ export type PluginClass = Class<PluginProto, ExternalPluginStatic>;
20
20
  /**
21
21
  * Static props for plugin classes
22
22
  */
23
- interface ExternalPluginStatic {
23
+ export interface ExternalPluginStatic {
24
24
  pluginName: string;
25
25
  }
26
26
 
@@ -28,7 +28,7 @@ interface ExternalPluginStatic {
28
28
  * A plugin must have this shape.
29
29
  * @todo Use base plugin instead of this
30
30
  */
31
- interface PluginProto {
31
+ export interface PluginProto {
32
32
  /**
33
33
  * I'm not sure why `plugin.name` is required, but it is.
34
34
  */
@@ -2,8 +2,8 @@
2
2
  * These types describe information about external extensions and the contents of their `package.json` files
3
3
  */
4
4
 
5
- import { SchemaObject } from 'ajv';
6
- import { PackageJson, SetRequired } from 'type-fest';
5
+ import type { SchemaObject } from 'ajv';
6
+ import type { PackageJson, SetRequired } from 'type-fest';
7
7
  import { DriverType, ExtensionType, PluginType } from './index';
8
8
 
9
9
  /**
@@ -5,3 +5,10 @@ export * from './cli';
5
5
  export type DriverType = 'driver';
6
6
  export type PluginType = 'plugin';
7
7
  export type ExtensionType = DriverType | PluginType;
8
+
9
+ /**
10
+ * Known environment variables concerning Appium
11
+ */
12
+ export interface AppiumEnv extends NodeJS.ProcessEnv {
13
+ APPIUM_HOME?: string;
14
+ }