appium 2.0.0-beta.46 → 2.0.0-beta.48

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 (141) hide show
  1. package/README.md +145 -44
  2. package/build/lib/appium.d.ts +3 -103
  3. package/build/lib/appium.d.ts.map +1 -1
  4. package/build/lib/appium.js +679 -549
  5. package/build/lib/appium.js.map +1 -1
  6. package/build/lib/cli/args.js +247 -127
  7. package/build/lib/cli/args.js.map +1 -1
  8. package/build/lib/cli/driver-command.d.ts +24 -5
  9. package/build/lib/cli/driver-command.d.ts.map +1 -1
  10. package/build/lib/cli/driver-command.js +78 -88
  11. package/build/lib/cli/driver-command.js.map +1 -1
  12. package/build/lib/cli/extension-command.d.ts +33 -24
  13. package/build/lib/cli/extension-command.d.ts.map +1 -1
  14. package/build/lib/cli/extension-command.js +729 -512
  15. package/build/lib/cli/extension-command.js.map +1 -1
  16. package/build/lib/cli/extension.d.ts +7 -6
  17. package/build/lib/cli/extension.d.ts.map +1 -1
  18. package/build/lib/cli/extension.js +68 -65
  19. package/build/lib/cli/extension.js.map +1 -1
  20. package/build/lib/cli/parser.d.ts +3 -3
  21. package/build/lib/cli/parser.d.ts.map +1 -1
  22. package/build/lib/cli/parser.js +234 -192
  23. package/build/lib/cli/parser.js.map +1 -1
  24. package/build/lib/cli/plugin-command.js +58 -87
  25. package/build/lib/cli/plugin-command.js.map +1 -1
  26. package/build/lib/cli/utils.js +66 -69
  27. package/build/lib/cli/utils.js.map +1 -1
  28. package/build/lib/config-file.d.ts.map +1 -1
  29. package/build/lib/config-file.js +189 -120
  30. package/build/lib/config-file.js.map +1 -1
  31. package/build/lib/config.d.ts.map +1 -1
  32. package/build/lib/config.js +254 -213
  33. package/build/lib/config.js.map +1 -1
  34. package/build/lib/constants.d.ts +6 -5
  35. package/build/lib/constants.d.ts.map +1 -1
  36. package/build/lib/constants.js +65 -59
  37. package/build/lib/constants.js.map +1 -1
  38. package/build/lib/extension/driver-config.js +199 -164
  39. package/build/lib/extension/driver-config.js.map +1 -1
  40. package/build/lib/extension/extension-config.d.ts +33 -26
  41. package/build/lib/extension/extension-config.d.ts.map +1 -1
  42. package/build/lib/extension/extension-config.js +541 -396
  43. package/build/lib/extension/extension-config.js.map +1 -1
  44. package/build/lib/extension/index.js +98 -68
  45. package/build/lib/extension/index.js.map +1 -1
  46. package/build/lib/extension/manifest-migrations.d.ts +27 -0
  47. package/build/lib/extension/manifest-migrations.d.ts.map +1 -0
  48. package/build/lib/extension/manifest-migrations.js +118 -0
  49. package/build/lib/extension/manifest-migrations.js.map +1 -0
  50. package/build/lib/extension/manifest.d.ts +35 -63
  51. package/build/lib/extension/manifest.d.ts.map +1 -1
  52. package/build/lib/extension/manifest.js +500 -240
  53. package/build/lib/extension/manifest.js.map +1 -1
  54. package/build/lib/extension/package-changed.js +57 -61
  55. package/build/lib/extension/package-changed.js.map +1 -1
  56. package/build/lib/extension/plugin-config.d.ts +2 -3
  57. package/build/lib/extension/plugin-config.d.ts.map +1 -1
  58. package/build/lib/extension/plugin-config.js +94 -70
  59. package/build/lib/extension/plugin-config.js.map +1 -1
  60. package/build/lib/grid-register.js +119 -137
  61. package/build/lib/grid-register.js.map +1 -1
  62. package/build/lib/logger.d.ts +1 -1
  63. package/build/lib/logger.d.ts.map +1 -1
  64. package/build/lib/logger.js +5 -15
  65. package/build/lib/logger.js.map +1 -1
  66. package/build/lib/logsink.d.ts.map +1 -1
  67. package/build/lib/logsink.js +189 -183
  68. package/build/lib/logsink.js.map +1 -1
  69. package/build/lib/main.d.ts +19 -12
  70. package/build/lib/main.d.ts.map +1 -1
  71. package/build/lib/main.js +330 -304
  72. package/build/lib/main.js.map +1 -1
  73. package/build/lib/schema/arg-spec.js +153 -108
  74. package/build/lib/schema/arg-spec.js.map +1 -1
  75. package/build/lib/schema/cli-args.js +203 -164
  76. package/build/lib/schema/cli-args.js.map +1 -1
  77. package/build/lib/schema/cli-transformers.js +117 -72
  78. package/build/lib/schema/cli-transformers.js.map +1 -1
  79. package/build/lib/schema/index.js +17 -32
  80. package/build/lib/schema/index.js.map +1 -1
  81. package/build/lib/schema/keywords.js +125 -67
  82. package/build/lib/schema/keywords.js.map +1 -1
  83. package/build/lib/schema/schema.d.ts.map +1 -1
  84. package/build/lib/schema/schema.js +582 -417
  85. package/build/lib/schema/schema.js.map +1 -1
  86. package/build/lib/utils.d.ts +41 -255
  87. package/build/lib/utils.d.ts.map +1 -1
  88. package/build/lib/utils.js +342 -193
  89. package/build/lib/utils.js.map +1 -1
  90. package/build/tsconfig.tsbuildinfo +1 -1
  91. package/build/types/cli.d.ts +45 -34
  92. package/build/types/cli.d.ts.map +1 -1
  93. package/build/types/cli.js +3 -0
  94. package/build/types/cli.js.map +1 -0
  95. package/build/types/index.d.ts +1 -2
  96. package/build/types/index.d.ts.map +1 -1
  97. package/build/types/index.js +19 -0
  98. package/build/types/index.js.map +1 -0
  99. package/build/types/manifest/base.d.ts +135 -0
  100. package/build/types/manifest/base.d.ts.map +1 -0
  101. package/build/types/manifest/base.js +3 -0
  102. package/build/types/manifest/base.js.map +1 -0
  103. package/build/types/manifest/index.d.ts +19 -0
  104. package/build/types/manifest/index.d.ts.map +1 -0
  105. package/build/types/manifest/index.js +40 -0
  106. package/build/types/manifest/index.js.map +1 -0
  107. package/build/types/manifest/v3.d.ts +139 -0
  108. package/build/types/manifest/v3.d.ts.map +1 -0
  109. package/build/types/manifest/v3.js +3 -0
  110. package/build/types/manifest/v3.js.map +1 -0
  111. package/lib/appium.js +1 -1
  112. package/lib/cli/args.js +1 -1
  113. package/lib/cli/driver-command.js +17 -0
  114. package/lib/cli/extension-command.js +119 -65
  115. package/lib/cli/extension.js +9 -8
  116. package/lib/cli/parser.js +2 -2
  117. package/lib/config-file.js +2 -3
  118. package/lib/config.js +3 -2
  119. package/lib/constants.js +7 -5
  120. package/lib/extension/extension-config.js +52 -47
  121. package/lib/extension/manifest-migrations.js +120 -0
  122. package/lib/extension/manifest.js +184 -103
  123. package/lib/extension/plugin-config.js +1 -2
  124. package/lib/logsink.js +26 -5
  125. package/lib/main.js +58 -50
  126. package/lib/schema/schema.js +6 -1
  127. package/lib/utils.js +62 -0
  128. package/package.json +24 -25
  129. package/scripts/autoinstall-extensions.js +78 -26
  130. package/types/cli.ts +81 -42
  131. package/types/index.ts +1 -2
  132. package/types/manifest/README.md +30 -0
  133. package/types/manifest/base.ts +158 -0
  134. package/types/manifest/index.ts +27 -0
  135. package/types/manifest/v3.ts +161 -0
  136. package/build/types/appium-manifest.d.ts +0 -59
  137. package/build/types/appium-manifest.d.ts.map +0 -1
  138. package/build/types/extension-manifest.d.ts +0 -55
  139. package/build/types/extension-manifest.d.ts.map +0 -1
  140. package/types/appium-manifest.ts +0 -73
  141. package/types/extension-manifest.ts +0 -64
package/lib/main.js CHANGED
@@ -23,10 +23,17 @@ import {
23
23
  } from './config';
24
24
  import {readConfigFile} from './config-file';
25
25
  import {loadExtensions, getActivePlugins, getActiveDrivers} from './extension';
26
- import {DRIVER_TYPE, PLUGIN_TYPE, SERVER_SUBCOMMAND} from './constants';
26
+ import {SERVER_SUBCOMMAND} from './constants';
27
27
  import registerNode from './grid-register';
28
28
  import {getDefaultsForSchema, validate} from './schema/schema';
29
- import {inspect, adjustNodePath} from './utils';
29
+ import {
30
+ inspect,
31
+ adjustNodePath,
32
+ isDriverCommandArgs,
33
+ isExtensionCommandArgs,
34
+ isPluginCommandArgs,
35
+ isServerCommandArgs,
36
+ } from './utils';
30
37
 
31
38
  const {resolveAppiumHome} = env;
32
39
 
@@ -143,16 +150,6 @@ function getExtraMethodMap(driverClasses, pluginClasses) {
143
150
  {}
144
151
  );
145
152
  }
146
-
147
- /**
148
- * @template [T=WithServerSubcommand]
149
- * @param {Args<T>} args
150
- * @returns {args is Args<WithServerSubcommand>}
151
- */
152
- function areServerCommandArgs(args) {
153
- return args.subcommand === SERVER_SUBCOMMAND;
154
- }
155
-
156
153
  /**
157
154
  * Initializes Appium, but does not start the server.
158
155
  *
@@ -160,9 +157,10 @@ function areServerCommandArgs(args) {
160
157
  *
161
158
  * If `args` contains a non-empty `subcommand` which is not `server`, this function will return an empty object.
162
159
  *
163
- * @template [T=WithServerSubcommand]
164
- * @param {Args<T>} [args] - Partial args (progammatic usage only)
165
- * @returns {Promise<ServerInitResult | ExtCommandInitResult>}
160
+ * @template {CliCommand} [Cmd=ServerCommand]
161
+ * @template {CliExtensionSubcommand|void} [SubCmd=void]
162
+ * @param {Args<Cmd, SubCmd>} [args] - Partial args (progammatic usage only)
163
+ * @returns {Promise<InitResult<Cmd>>}
166
164
  * @example
167
165
  * import {init, getSchema} from 'appium';
168
166
  * const options = {}; // config object
@@ -178,7 +176,7 @@ async function init(args) {
178
176
 
179
177
  const parser = getParser();
180
178
  let throwInsteadOfExit = false;
181
- /** @type {Args<T>} */
179
+ /** @type {Args<Cmd, SubCmd>} */
182
180
  let preConfigArgs;
183
181
 
184
182
  if (args) {
@@ -193,7 +191,7 @@ async function init(args) {
193
191
  preConfigArgs = {...args, subcommand: args.subcommand ?? SERVER_SUBCOMMAND};
194
192
  } else {
195
193
  // otherwise parse from CLI
196
- preConfigArgs = /** @type {Args<T>} */ (parser.parseArgs());
194
+ preConfigArgs = /** @type {Args<Cmd, SubCmd>} */ (parser.parseArgs());
197
195
  }
198
196
 
199
197
  const configResult = await readConfigFile(preConfigArgs.configFile);
@@ -211,15 +209,15 @@ async function init(args) {
211
209
  // 1. command line args
212
210
  // 2. config file
213
211
  // 3. defaults from config file.
214
- if (areServerCommandArgs(preConfigArgs)) {
212
+ if (isServerCommandArgs(preConfigArgs)) {
215
213
  const defaults = getDefaultsForSchema(false);
216
214
 
217
215
  /** @type {ParsedArgs} */
218
- const serverArgs = _.defaultsDeep(preConfigArgs, configResult.config?.server, defaults);
216
+ const serverArgs = _.defaultsDeep({}, preConfigArgs, configResult.config?.server, defaults);
219
217
 
220
218
  if (preConfigArgs.showConfig) {
221
219
  showConfig(getNonDefaultServerArgs(preConfigArgs), configResult, defaults, serverArgs);
222
- return {};
220
+ return /** @type {InitResult<Cmd>} */ ({});
223
221
  }
224
222
 
225
223
  await logsinkInit(serverArgs);
@@ -252,49 +250,49 @@ async function init(args) {
252
250
  appiumDriver.driverConfig = driverConfig;
253
251
  await preflightChecks(serverArgs, throwInsteadOfExit);
254
252
 
255
- return /** @type {ServerInitResult} */ ({
253
+ return /** @type {InitResult<Cmd>} */ ({
256
254
  appiumDriver,
257
255
  parsedArgs: serverArgs,
258
256
  driverConfig,
259
257
  pluginConfig,
260
258
  });
261
259
  } else {
262
- const extensionCommandArgs = /** @type {Args<import('appium/types').WithExtSubcommand>} */ (
263
- preConfigArgs
264
- );
265
- // if the user has requested the 'driver' CLI, don't run the normal server,
266
- // but instead pass control to the driver CLI
267
- if (preConfigArgs.subcommand === DRIVER_TYPE) {
268
- await runExtensionCommand(extensionCommandArgs, driverConfig);
269
- return {};
270
- }
271
- if (preConfigArgs.subcommand === PLUGIN_TYPE) {
272
- await runExtensionCommand(extensionCommandArgs, pluginConfig);
273
- return {};
260
+ if (isExtensionCommandArgs(preConfigArgs)) {
261
+ // if the user has requested the 'driver' CLI, don't run the normal server,
262
+ // but instead pass control to the driver CLI
263
+ if (isDriverCommandArgs(preConfigArgs)) {
264
+ await runExtensionCommand(preConfigArgs, driverConfig);
265
+ }
266
+ if (isPluginCommandArgs(preConfigArgs)) {
267
+ await runExtensionCommand(preConfigArgs, pluginConfig);
268
+ }
274
269
  }
275
- /* istanbul ignore next */
276
- return {}; // should never happen
270
+ return /** @type {InitResult<Cmd>} */ ({});
277
271
  }
278
272
  }
279
273
 
280
274
  /**
281
275
  * Initializes Appium's config. Starts server if appropriate and resolves the
282
276
  * server instance if so; otherwise resolves w/ `undefined`.
283
- * @template [T=WithServerSubcommand]
284
- * @param {Args<T>} [args] - Arguments from CLI or otherwise
285
- * @returns {Promise<import('@appium/types').AppiumServer|undefined>}
277
+ * @template {CliCommand} [Cmd=ServerCommand]
278
+ * @template {CliExtensionSubcommand|void} [SubCmd=void]
279
+ * @param {Args<Cmd, SubCmd>} [args] - Arguments from CLI or otherwise
280
+ * @returns {Promise<Cmd extends ServerCommand ? import('@appium/types').AppiumServer : void>}
286
281
  */
287
282
  async function main(args) {
288
- const {appiumDriver, parsedArgs, pluginConfig, driverConfig} = /** @type {ServerInitResult} */ (
289
- await init(args)
290
- );
283
+ const initResult = await init(args);
291
284
 
292
- if (!appiumDriver || !parsedArgs || !pluginConfig || !driverConfig) {
285
+ if (_.isEmpty(initResult)) {
293
286
  // if this branch is taken, we've run a different subcommand, so there's nothing
294
287
  // left to do here.
295
- return;
288
+ return /** @type {Cmd extends ServerCommand ? import('@appium/types').AppiumServer : void} */ (
289
+ undefined
290
+ );
296
291
  }
297
292
 
293
+ const {appiumDriver, pluginConfig, driverConfig, parsedArgs} =
294
+ /** @type {InitResult<ServerCommand>} */ (initResult);
295
+
298
296
  const pluginClasses = getActivePlugins(pluginConfig, parsedArgs.usePlugins);
299
297
  // set the active plugins on the umbrella driver so it can use them for commands
300
298
  appiumDriver.pluginClasses = pluginClasses;
@@ -377,7 +375,9 @@ async function main(args) {
377
375
  driverConfig.print();
378
376
  pluginConfig.print([...pluginClasses.values()]);
379
377
 
380
- return server;
378
+ return /** @type {Cmd extends ServerCommand ? import('@appium/types').AppiumServer : void} */ (
379
+ server
380
+ );
381
381
  }
382
382
 
383
383
  // NOTE: this is here for backwards compat for any scripts referencing `main.js` directly
@@ -397,7 +397,12 @@ export {main, init, resolveAppiumHome};
397
397
  * @typedef {import('@appium/types').PluginType} PluginType
398
398
  * @typedef {import('@appium/types').DriverClass} DriverClass
399
399
  * @typedef {import('@appium/types').PluginClass} PluginClass
400
- * @typedef {import('appium/types').WithServerSubcommand} WithServerSubcommand
400
+ * @typedef {import('appium/types').CliCommand} CliCommand
401
+ * @typedef {import('appium/types').CliExtensionSubcommand} CliExtensionSubcommand
402
+ * @typedef {import('appium/types').CliExtensionCommand} CliExtensionCommand
403
+ * @typedef {import('appium/types').ServerCommand} ServerCommand
404
+ * @typedef {import('appium/types').DriverCommand} DriverCommand
405
+ * @typedef {import('appium/types').PluginCommand} PluginCommand
401
406
  * @typedef {import('./extension').DriverNameMap} DriverNameMap
402
407
  * @typedef {import('./extension').PluginNameMap} PluginNameMap
403
408
  */
@@ -414,15 +419,18 @@ export {main, init, resolveAppiumHome};
414
419
  */
415
420
 
416
421
  /**
417
- * @typedef {ServerInitData & import('./extension').ExtensionConfigs} ServerInitResult
422
+ * @template {CliCommand} Cmd
423
+ * @typedef {Cmd extends ServerCommand ? ServerInitData & import('./extension').ExtensionConfigs : ExtCommandInitResult} InitResult
418
424
  */
419
425
 
420
426
  /**
421
- * @template [T=WithServerSubcommand]
422
- * @typedef {import('appium/types').Args<T>} Args
427
+ * @template {CliCommand} [Cmd=ServerCommand]
428
+ * @template {CliExtensionSubcommand|void} [SubCmd=void]
429
+ * @typedef {import('appium/types').Args<Cmd, SubCmd>} Args
423
430
  */
424
431
 
425
432
  /**
426
- * @template [T=WithServerSubcommand]
427
- * @typedef {import('appium/types').ParsedArgs<T>} ParsedArgs
433
+ * @template {CliCommand} [Cmd=ServerCommand]
434
+ * @template {CliExtensionSubcommand|void} [SubCmd=void]
435
+ * @typedef {import('appium/types').ParsedArgs<Cmd, SubCmd>} ParsedArgs
428
436
  */
@@ -43,6 +43,8 @@ export class RoachHotelMap extends Map {
43
43
  */
44
44
  export const ALLOWED_SCHEMA_EXTENSIONS = new Set(['.json', '.js', '.cjs']);
45
45
 
46
+ const SCHEMA_KEY = '$schema';
47
+
46
48
  /**
47
49
  * A wrapper around Ajv and schema-related functions.
48
50
  *
@@ -316,7 +318,7 @@ class AppiumSchema {
316
318
  }
317
319
  const normalizedExtName = _.kebabCase(extName);
318
320
  if (this.hasRegisteredSchema(extType, normalizedExtName)) {
319
- if (this._registeredSchemas[extType].get(normalizedExtName) === schema) {
321
+ if (_.isEqual(this._registeredSchemas[extType].get(normalizedExtName), schema)) {
320
322
  return;
321
323
  }
322
324
  throw new SchemaNameConflictError(extType, extName);
@@ -441,6 +443,9 @@ class AppiumSchema {
441
443
  for (const {properties, prefix} of stack) {
442
444
  const pairs = _.toPairs(properties);
443
445
  for (const [key, value] of pairs) {
446
+ if (key === SCHEMA_KEY) {
447
+ continue;
448
+ }
444
449
  const {properties, $ref} = value;
445
450
  if (properties) {
446
451
  stack.push({
package/lib/utils.js CHANGED
@@ -4,6 +4,7 @@ import {processCapabilities, PROTOCOLS, STANDARD_CAPS} from '@appium/base-driver
4
4
  import {inspect as dump} from 'util';
5
5
  import {node} from '@appium/support';
6
6
  import path from 'path';
7
+ import {SERVER_SUBCOMMAND, DRIVER_TYPE, PLUGIN_TYPE} from './constants';
7
8
 
8
9
  const W3C_APPIUM_PREFIX = 'appium';
9
10
  const STANDARD_CAPS_LOWERCASE = new Set([...STANDARD_CAPS].map((cap) => cap.toLowerCase()));
@@ -289,6 +290,46 @@ function pullSettings(caps) {
289
290
  return result;
290
291
  }
291
292
 
293
+ /**
294
+ * @template {CliCommand} [Cmd=ServerCommand]
295
+ * @template {CliExtensionSubcommand|void} [SubCmd=void]
296
+ * @param {Args<Cmd, SubCmd>} args
297
+ * @returns {args is Args<ServerCommand>}
298
+ */
299
+ export function isServerCommandArgs(args) {
300
+ return args.subcommand === SERVER_SUBCOMMAND;
301
+ }
302
+
303
+ /**
304
+ * @template {CliCommand} [Cmd=ServerCommand]
305
+ * @template {CliExtensionSubcommand|void} [SubCmd=void]
306
+ * @param {Args<Cmd, SubCmd>} args
307
+ * @returns {args is Args<CliExtensionCommand, SubCmd>}
308
+ */
309
+ export function isExtensionCommandArgs(args) {
310
+ return args.subcommand === DRIVER_TYPE || args.subcommand === PLUGIN_TYPE;
311
+ }
312
+
313
+ /**
314
+ * @template {CliCommand} Cmd
315
+ * @template {CliExtensionSubcommand} SubCmd
316
+ * @param {Args<Cmd, SubCmd>} args
317
+ * @returns {args is Args<DriverCommand, SubCmd>}
318
+ */
319
+ export function isDriverCommandArgs(args) {
320
+ return args.subcommand === DRIVER_TYPE;
321
+ }
322
+
323
+ /**
324
+ * @template {CliCommand} Cmd
325
+ * @template {CliExtensionSubcommand} SubCmd
326
+ * @param {Args<Cmd, SubCmd>} args
327
+ * @returns {args is Args<PluginCommand, SubCmd>}
328
+ */
329
+ export function isPluginCommandArgs(args) {
330
+ return args.subcommand === PLUGIN_TYPE;
331
+ }
332
+
292
333
  export {
293
334
  inspect,
294
335
  parseCapsForInnerDriver,
@@ -357,3 +398,24 @@ export {
357
398
  /**
358
399
  * @typedef {import('@appium/types').Constraints} Constraints
359
400
  */
401
+
402
+ /**
403
+ * @typedef {import('appium/types').CliCommand} CliCommand
404
+ * @typedef {import('appium/types').CliExtensionSubcommand} CliExtensionSubcommand
405
+ * @typedef {import('appium/types').CliExtensionCommand} CliExtensionCommand
406
+ * @typedef {import('appium/types').ServerCommand} ServerCommand
407
+ * @typedef {import('appium/types').DriverCommand} DriverCommand
408
+ * @typedef {import('appium/types').PluginCommand} PluginCommand
409
+ */
410
+
411
+ /**
412
+ * @template {CliCommand} [Cmd=ServerCommand]
413
+ * @template {CliExtensionSubcommand|void} [SubCmd=void]
414
+ * @typedef {import('appium/types').Args<Cmd, SubCmd>} Args
415
+ */
416
+
417
+ /**
418
+ * @template {CliCommand} [Cmd=ServerCommand]
419
+ * @template {CliExtensionSubcommand|void} [SubCmd=void]
420
+ * @typedef {import('appium/types').ParsedArgs<Cmd, SubCmd>} ParsedArgs
421
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium",
3
- "version": "2.0.0-beta.46",
3
+ "version": "2.0.0-beta.48",
4
4
  "description": "Automation for Apps.",
5
5
  "keywords": [
6
6
  "automation",
@@ -41,45 +41,41 @@
41
41
  "types"
42
42
  ],
43
43
  "scripts": {
44
- "build": "babel lib --root-mode=upward --out-dir=build/lib",
45
44
  "build:docs": "node docs/scripts/build-docs.js",
46
- "build:docs:cli": "node docs/scripts/gen-cli-args-docs.js",
47
45
  "build:docs:assets": "node docs/scripts/copy-assets.js",
48
- "dev": "npm run build -- --watch",
46
+ "build:docs:cli": "node docs/scripts/gen-cli-args-docs.js",
47
+ "build:docs:reference": "node docs/scripts/build-reference.js",
49
48
  "dev:docs": "npm run build:docs:assets && npm run dev:docs:en",
50
49
  "dev:docs:en": "mkdocs serve -f ./docs/mkdocs-en.yml",
51
50
  "dev:docs:ja": "mkdocs serve -f ./docs/mkdocs-ja.yml",
52
51
  "dev:docs:zh": "mkdocs serve -f ./docs/mkdocs-zh.yml",
53
- "fix": "npm run lint -- --fix",
54
52
  "postinstall": "node ./scripts/autoinstall-extensions.js",
55
- "lint": "eslint -c ../../.eslintrc --ignore-path ../../.eslintignore .",
56
- "prepare": "npm run build",
57
53
  "publish:docs": "cross-env APPIUM_DOCS_PUBLISH=1 npm run build:docs",
58
54
  "test": "npm run test:unit",
59
- "test:e2e": "mocha --timeout 1m --slow 30s \"./test/e2e/**/*.spec.js\"",
55
+ "test:e2e": "mocha -p --timeout 1m --slow 30s \"./test/e2e/**/*.spec.js\"",
60
56
  "test:smoke": "cross-env APPIUM_HOME=./local_appium_home node ./index.js driver install uiautomator2 && cross-env APPIUM_HOME=./local_appium_home node ./index.js driver list",
61
57
  "test:unit": "mocha \"./test/unit/**/*.spec.js\""
62
58
  },
63
59
  "dependencies": {
64
- "@appium/base-driver": "^8.7.3",
65
- "@appium/base-plugin": "^1.10.5",
66
- "@appium/docutils": "^0.0.13",
67
- "@appium/schema": "^0.0.9",
68
- "@appium/support": "^2.61.1",
69
- "@appium/types": "^0.5.0",
60
+ "@appium/base-driver": "^9.1.0",
61
+ "@appium/base-plugin": "^2.0.1",
62
+ "@appium/docutils": "^0.1.1",
63
+ "@appium/schema": "^0.1.0",
64
+ "@appium/support": "^3.0.1",
65
+ "@appium/types": "^0.7.0",
70
66
  "@sidvind/better-ajv-errors": "2.1.0",
71
67
  "@types/argparse": "2.0.10",
72
- "@types/bluebird": "3.5.37",
68
+ "@types/bluebird": "3.5.38",
73
69
  "@types/fancy-log": "2.0.0",
74
- "@types/semver": "7.3.12",
75
- "@types/teen_process": "1.16.1",
70
+ "@types/semver": "7.3.13",
71
+ "@types/teen_process": "2.0.0",
76
72
  "@types/wrap-ansi": "3.0.0",
77
- "ajv": "8.11.0",
73
+ "ajv": "8.11.2",
78
74
  "ajv-formats": "2.1.1",
79
75
  "argparse": "2.0.1",
80
- "async-lock": "1.3.2",
81
- "asyncbox": "2.9.2",
82
- "axios": "0.27.2",
76
+ "async-lock": "1.4.0",
77
+ "asyncbox": "2.9.4",
78
+ "axios": "1.2.1",
83
79
  "bluebird": "3.7.2",
84
80
  "cross-env": "7.0.3",
85
81
  "find-up": "5.0.0",
@@ -87,25 +83,28 @@
87
83
  "lilconfig": "2.0.6",
88
84
  "lodash": "4.17.21",
89
85
  "longjohn": "0.2.12",
90
- "npmlog": "6.0.2",
86
+ "npmlog": "7.0.1",
91
87
  "ora": "5.4.1",
92
88
  "package-changed": "1.9.0",
93
89
  "resolve-from": "5.0.0",
94
90
  "semver": "7.3.8",
95
91
  "source-map-support": "0.5.21",
96
92
  "teen_process": "2.0.2",
97
- "type-fest": "3.1.0",
93
+ "type-fest": "3.4.0",
98
94
  "winston": "3.8.2",
99
95
  "wrap-ansi": "7.0.0",
100
96
  "yaml": "2.1.3"
101
97
  },
102
98
  "engines": {
103
- "node": ">=14",
99
+ "node": "^14.17.0 || ^16.13.0 || >=18.0.0",
104
100
  "npm": ">=8"
105
101
  },
106
102
  "publishConfig": {
107
103
  "access": "public",
108
104
  "tag": "next"
109
105
  },
110
- "gitHead": "6b3cc1a8743f78c1f50320364f25f3011d2b2136"
106
+ "gitHead": "2e76ba9607729f59ca967e47c2cba738e90a57b8",
107
+ "typedoc": {
108
+ "entryPoint": "./build/lib/main.js"
109
+ }
111
110
  }
@@ -14,10 +14,24 @@
14
14
  * code upon failure (which will typically break a build). Otherwise, it
15
15
  * will always exit with code 0, even if errors occur.
16
16
  *
17
+ * @module
17
18
  * @example
18
19
  * `npm install -g appium --drivers=uiautomator2,xcuitest --plugins=images`
19
20
  */
20
21
 
22
+ const path = require('path');
23
+ const {exec} = require('teen_process');
24
+ const B = require('bluebird');
25
+
26
+ B.config({
27
+ cancellation: true,
28
+ });
29
+
30
+ /**
31
+ * This is only used if we're actually in the monorepo
32
+ */
33
+ const MONOREPO_ROOT = path.join(__dirname, '..', '..', '..');
34
+
21
35
  /** @type {import('../lib/cli/extension').runExtensionCommand} */
22
36
  let runExtensionCommand;
23
37
  /** @type {import('../lib/constants').DRIVER_TYPE} */
@@ -27,44 +41,82 @@ let PLUGIN_TYPE;
27
41
  /** @type {import('../lib/extension').loadExtensions} */
28
42
  let loadExtensions;
29
43
 
30
- const {env, util, logger} = require('@appium/support');
31
44
  const _ = require('lodash');
32
45
  const wrap = _.partial(
33
46
  require('wrap-ansi'),
34
47
  _,
35
- process.stderr.columns ?? process.stdout.columns ?? 25
48
+ process.stderr.columns ?? process.stdout.columns ?? 80
36
49
  );
37
-
38
50
  const ora = require('ora');
39
51
 
40
- const log = (message) => {
52
+ let env, util, logger;
53
+
54
+ function log(message) {
41
55
  console.error(wrap(`[Appium] ${message}`));
42
- };
43
-
44
- const spinner = ora({
45
- text: 'Checking Appium installation...',
46
- prefixText: '[Appium]',
47
- }).start();
48
-
49
- try {
50
- ({runExtensionCommand} = require('../build/lib/cli/extension'));
51
- ({DRIVER_TYPE, PLUGIN_TYPE} = require('../build/lib/constants'));
52
- ({loadExtensions} = require('../build/lib/extension'));
53
- spinner.succeed('Appium installation OK');
54
- // suppress logs from Appium, which mess up the script output
55
- logger.getLogger('Appium').level = 'error';
56
- } catch (e) {
57
- spinner.fail(`Could not load required module(s); has Appium been built? (${e.message})`);
58
- if (process.env.CI) {
59
- console.error('Detected CI environment, exiting with code 1');
60
- process.exitCode = 1;
61
- } else {
62
- process.exitCode = 0;
56
+ }
57
+
58
+ async function init() {
59
+ /** @type {import('ora').Ora} */
60
+ let spinner;
61
+
62
+ try {
63
+ ({env, util, logger} = require('@appium/support'));
64
+ require('..');
65
+ } catch {
66
+ spinner = ora({
67
+ text: 'Building Appium dev environment...',
68
+ prefixText: '[Appium]',
69
+ }).start();
70
+
71
+ try {
72
+ const {stderr, code} = await exec('npm', ['run', 'build'], {
73
+ cwd: MONOREPO_ROOT,
74
+ encoding: 'utf8',
75
+ });
76
+ if (!code) {
77
+ spinner.succeed('Appium build successfully.');
78
+ } else {
79
+ spinner.fail(`Building Appium failed!`);
80
+ log(stderr);
81
+ }
82
+ } catch (err) {
83
+ spinner.fail(`Building Appium failed!`);
84
+ log(err);
85
+ }
86
+ }
87
+
88
+ spinner = ora({
89
+ text: 'Checking Appium installation...',
90
+ prefixText: '[Appium]',
91
+ }).start();
92
+
93
+ try {
94
+ ({env, util, logger} = require('@appium/support'));
95
+ ({runExtensionCommand} = require('../build/lib/cli/extension'));
96
+ ({DRIVER_TYPE, PLUGIN_TYPE} = require('../build/lib/constants'));
97
+ ({loadExtensions} = require('../build/lib/extension'));
98
+ spinner.succeed('Appium installation OK');
99
+ // suppress logs from Appium, which mess up the script output
100
+ logger.getLogger('Appium').level = 'error';
101
+ } catch (e) {
102
+ spinner.fail(`Could not load required module(s); has Appium been built? (${e.message})`);
103
+ if (process.env.CI) {
104
+ log('Detected CI environment, exiting with code 1');
105
+ process.exitCode = 1;
106
+ } else {
107
+ process.exitCode = 0;
108
+ }
109
+ return false;
63
110
  }
64
- process.exit();
111
+
112
+ return true;
65
113
  }
66
114
 
67
115
  async function main() {
116
+ if (!(await init())) {
117
+ return;
118
+ }
119
+
68
120
  // if we're doing `npm install -g appium` then we will assume we don't have a local appium.
69
121
  if (!process.env.npm_config_global && (await env.hasAppiumDependency())) {
70
122
  log(`Found local Appium installation; skipping automatic installation of extensions.`);