appium 3.1.2 → 3.2.1

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 (79) hide show
  1. package/README.md +4 -4
  2. package/build/lib/appium.d.ts +2 -2
  3. package/build/lib/appium.d.ts.map +1 -1
  4. package/build/lib/appium.js +5 -7
  5. package/build/lib/appium.js.map +1 -1
  6. package/build/lib/bidi-commands.d.ts +1 -1
  7. package/build/lib/bidi-commands.d.ts.map +1 -1
  8. package/build/lib/bidi-commands.js.map +1 -1
  9. package/build/lib/cli/extension-command.d.ts +109 -0
  10. package/build/lib/cli/extension-command.d.ts.map +1 -1
  11. package/build/lib/cli/extension-command.js +255 -96
  12. package/build/lib/cli/extension-command.js.map +1 -1
  13. package/build/lib/cli/parser.d.ts +10 -0
  14. package/build/lib/cli/parser.d.ts.map +1 -1
  15. package/build/lib/cli/parser.js +20 -2
  16. package/build/lib/cli/parser.js.map +1 -1
  17. package/build/lib/constants.js +3 -3
  18. package/build/lib/constants.js.map +1 -1
  19. package/build/lib/extension/extension-config.js +7 -7
  20. package/build/lib/extension/extension-config.js.map +1 -1
  21. package/build/lib/extension/manifest.js +6 -6
  22. package/build/lib/extension/manifest.js.map +1 -1
  23. package/build/lib/extension/package-changed.js +3 -3
  24. package/build/lib/extension/package-changed.js.map +1 -1
  25. package/build/lib/inspector-commands.d.ts.map +1 -1
  26. package/build/lib/logger.d.ts +1 -1
  27. package/build/lib/logger.d.ts.map +1 -1
  28. package/build/lib/logsink.d.ts.map +1 -1
  29. package/build/lib/logsink.js +9 -7
  30. package/build/lib/logsink.js.map +1 -1
  31. package/build/lib/main.d.ts.map +1 -1
  32. package/build/lib/main.js +11 -2
  33. package/build/lib/main.js.map +1 -1
  34. package/build/lib/schema/cli-args.d.ts.map +1 -1
  35. package/build/lib/schema/cli-args.js +5 -0
  36. package/build/lib/schema/cli-args.js.map +1 -1
  37. package/build/lib/schema/cli-transformers.js +5 -5
  38. package/build/lib/schema/cli-transformers.js.map +1 -1
  39. package/build/lib/schema/schema.js +2 -2
  40. package/build/lib/schema/schema.js.map +1 -1
  41. package/build/lib/utils.d.ts +1 -1
  42. package/build/lib/utils.d.ts.map +1 -1
  43. package/build/lib/utils.js +8 -8
  44. package/build/lib/utils.js.map +1 -1
  45. package/build/package.json +99 -0
  46. package/build/types/cli.d.ts +3 -3
  47. package/build/types/cli.d.ts.map +1 -1
  48. package/build/types/index.d.ts +1 -1
  49. package/build/types/index.d.ts.map +1 -1
  50. package/build/types/manifest/base.d.ts +3 -3
  51. package/build/types/manifest/base.d.ts.map +1 -1
  52. package/build/types/manifest/v3.d.ts +3 -3
  53. package/build/types/manifest/v3.d.ts.map +1 -1
  54. package/build/types/manifest/v4.d.ts +3 -3
  55. package/build/types/manifest/v4.d.ts.map +1 -1
  56. package/index.js +1 -3
  57. package/lib/appium.js +5 -7
  58. package/lib/bidi-commands.ts +4 -6
  59. package/lib/cli/extension-command.js +283 -105
  60. package/lib/cli/parser.js +21 -2
  61. package/lib/constants.js +1 -1
  62. package/lib/extension/extension-config.js +2 -2
  63. package/lib/extension/manifest.js +1 -1
  64. package/lib/extension/package-changed.js +1 -1
  65. package/lib/inspector-commands.ts +1 -1
  66. package/lib/logsink.js +11 -7
  67. package/lib/main.js +13 -3
  68. package/lib/schema/cli-args.js +6 -0
  69. package/lib/schema/cli-transformers.js +1 -1
  70. package/lib/schema/schema.js +1 -1
  71. package/lib/utils.js +3 -3
  72. package/package.json +22 -24
  73. package/scripts/autoinstall-extensions.js +7 -10
  74. package/tsconfig.json +5 -2
  75. package/types/cli.ts +4 -4
  76. package/types/index.ts +1 -1
  77. package/types/manifest/base.ts +3 -3
  78. package/types/manifest/v3.ts +3 -3
  79. package/types/manifest/v4.ts +3 -3
package/lib/logsink.js CHANGED
@@ -5,10 +5,6 @@ import _ from 'lodash';
5
5
  import { adler32 } from './utils';
6
6
  import { LRUCache } from 'lru-cache';
7
7
 
8
- // set up distributed logging before everything else
9
- global._global_npmlog = globalLog;
10
- // npmlog is used only for emitting, we use winston for output
11
- globalLog.level = 'info';
12
8
  const LEVELS_MAP = {
13
9
  debug: 4,
14
10
  info: 3,
@@ -42,6 +38,7 @@ const COLORS_CACHE = new LRUCache({
42
38
  updateAgeOnGet: true,
43
39
  });
44
40
 
41
+ // npmlog is used only for emitting, we use winston for output (global is set by support)
45
42
  /** @type {import('winston').Logger?} */
46
43
  let log = null;
47
44
 
@@ -102,6 +99,8 @@ export async function init(args) {
102
99
  }
103
100
  }
104
101
  });
102
+ // Only Winston produces output; avoid duplicate lines from the logger's default stream
103
+ globalLog.stream = null;
105
104
  }
106
105
 
107
106
  /**
@@ -211,12 +210,17 @@ async function createTransports(args) {
211
210
  let consoleLogLevel;
212
211
  /** @type {string} */
213
212
  let fileLogLevel;
214
- if (args.loglevel && args.loglevel.match(':')) {
213
+
214
+ // Server args are normalized in main so we only see dest form (`loglevel`).
215
+ // Fall back to schema default so Winston never sees undefined.
216
+ const rawLogLevel = args.loglevel ?? 'debug';
217
+
218
+ if (rawLogLevel && rawLogLevel.includes(':')) {
215
219
  // --log-level arg can optionally provide diff logging levels for console and file, separated by a colon
216
- const lvlPair = args.loglevel.split(':');
220
+ const lvlPair = rawLogLevel.split(':');
217
221
  [consoleLogLevel, fileLogLevel] = lvlPair;
218
222
  } else {
219
- consoleLogLevel = fileLogLevel = args.loglevel;
223
+ consoleLogLevel = fileLogLevel = rawLogLevel;
220
224
  }
221
225
 
222
226
  transports.push(createConsoleTransport(args, consoleLogLevel));
package/lib/main.js CHANGED
@@ -9,12 +9,11 @@ import {
9
9
  normalizeBasePath,
10
10
  } from '@appium/base-driver';
11
11
  import {util, env} from '@appium/support';
12
- import {asyncify} from 'asyncbox';
13
12
  import _ from 'lodash';
14
13
  import {AppiumDriver} from './appium';
15
14
  import {runExtensionCommand} from './cli/extension';
16
15
  import { runSetupCommand } from './cli/setup-command';
17
- import {getParser} from './cli/parser';
16
+ import {getParser, ArgParser} from './cli/parser';
18
17
  import {
19
18
  APPIUM_VER,
20
19
  checkNodeOk,
@@ -43,6 +42,7 @@ import {
43
42
  isBroadcastIp,
44
43
  } from './utils';
45
44
  import net from 'node:net';
45
+ import { injectAppiumSymlinks } from './cli/extension-command';
46
46
 
47
47
  const {resolveAppiumHome} = env;
48
48
  /*
@@ -211,6 +211,8 @@ async function init(args) {
211
211
  delete args.throwInsteadOfExit;
212
212
  }
213
213
  preConfigArgs = {...args, subcommand: args.subcommand ?? SERVER_SUBCOMMAND};
214
+ // Normalize hyphenated keys to dest form so programmatic args match CLI shape
215
+ ArgParser.normalizeServerArgs(preConfigArgs);
214
216
  } else {
215
217
  // otherwise parse from CLI
216
218
  preConfigArgs = /** @type {Args<Cmd, SubCmd>} */ (parser.parseArgs());
@@ -314,6 +316,14 @@ async function init(args) {
314
316
  if (isPluginCommandArgs(preConfigArgs)) {
315
317
  await runExtensionCommand(preConfigArgs, pluginConfig);
316
318
  }
319
+
320
+ if (isDriverCommandArgs(preConfigArgs) || isPluginCommandArgs(preConfigArgs)) {
321
+ // @ts-ignore The linter suggest using dot
322
+ const cmd = preConfigArgs.driverCommand || preConfigArgs.pluginCommand;
323
+ if (cmd === 'install') {
324
+ await injectAppiumSymlinks(driverConfig, pluginConfig, logger);
325
+ }
326
+ }
317
327
  }
318
328
  return /** @type {InitResult<Cmd>} */ ({});
319
329
  }
@@ -481,7 +491,7 @@ async function main(args) {
481
491
  // (more specifically, `build/lib/main.js`)
482
492
  // the executable is now `../index.js`, so that module will typically be `require.main`.
483
493
  if (require.main === module) {
484
- asyncify(main);
494
+ main();
485
495
  }
486
496
 
487
497
  // everything below here is intended to be a public API.
@@ -112,6 +112,12 @@ function subSchemaToArgDef(subSchema, argSpec) {
112
112
  help: makeDescription(subSchema),
113
113
  };
114
114
 
115
+ // argparse infers dest from the option string (e.g. --log-level → log_level).
116
+ // We need schema dest (e.g. loglevel) so merged server args and logsink use the right key.
117
+ if (!argSpec.extType) {
118
+ argOpts.dest = argSpec.rawDest;
119
+ }
120
+
115
121
  /**
116
122
  * Generally we will provide a `type` to `argparse` as a function which
117
123
  * validates using ajv (which is much more full-featured than what `argparse`
@@ -1,5 +1,5 @@
1
1
  import {ArgumentTypeError} from 'argparse';
2
- import {readFileSync, existsSync} from 'fs';
2
+ import {readFileSync, existsSync} from 'node:fs';
3
3
 
4
4
  /**
5
5
  * This module provides custom keywords for Appium schemas, as well as
@@ -1,7 +1,7 @@
1
1
  import {Ajv} from 'ajv';
2
2
  import addFormats from 'ajv-formats';
3
3
  import _ from 'lodash';
4
- import path from 'path';
4
+ import path from 'node:path';
5
5
  import {DRIVER_TYPE, PLUGIN_TYPE} from '../constants';
6
6
  import {AppiumConfigJsonSchema} from '@appium/schema';
7
7
  import {APPIUM_CONFIG_SCHEMA_ID, ArgSpec, SERVER_PROP_NAME} from './arg-spec';
package/lib/utils.js CHANGED
@@ -6,9 +6,9 @@ import {
6
6
  errors,
7
7
  isW3cCaps,
8
8
  } from '@appium/base-driver';
9
- import {inspect as dump} from 'util';
9
+ import {inspect as dump} from 'node:util';
10
10
  import {node, fs} from '@appium/support';
11
- import path from 'path';
11
+ import path from 'node:path';
12
12
  import {SERVER_SUBCOMMAND, DRIVER_TYPE, PLUGIN_TYPE, SETUP_SUBCOMMAND} from './constants';
13
13
  import os from 'node:os';
14
14
 
@@ -229,7 +229,7 @@ export function adjustNodePath() {
229
229
  // See https://gist.github.com/branneman/8048520#7-the-hack
230
230
  // @ts-ignore see above comment
231
231
 
232
- require('module').Module._initPaths();
232
+ require('node:module').Module._initPaths();
233
233
  return true;
234
234
  } catch {
235
235
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium",
3
- "version": "3.1.2",
3
+ "version": "3.2.1",
4
4
  "description": "Automation for Apps.",
5
5
  "keywords": [
6
6
  "automation",
@@ -40,7 +40,8 @@
40
40
  "scripts/autoinstall-extensions.js",
41
41
  "types",
42
42
  "tsconfig.json",
43
- "!build/tsconfig.tsbuildinfo"
43
+ "!build/tsconfig.tsbuildinfo",
44
+ "!build/test"
44
45
  ],
45
46
  "scripts": {
46
47
  "build:docs": "node docs/scripts/build-docs.js",
@@ -55,39 +56,36 @@
55
56
  "postinstall": "node ./scripts/autoinstall-extensions.js",
56
57
  "publish:docs": "cross-env APPIUM_DOCS_PUBLISH=1 npm run build:docs",
57
58
  "test": "npm run test:unit",
58
- "test:e2e": "mocha --exit --timeout 1m --slow 30s \"./test/e2e/**/*.spec.js\"",
59
+ "test:e2e": "mocha --exit --timeout 1m --slow 30s \"./test/e2e/**/*.spec.ts\"",
59
60
  "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",
60
- "test:unit": "mocha \"./test/unit/**/*.spec.js\""
61
+ "test:unit": "mocha \"./test/unit/**/*.spec.ts\""
61
62
  },
62
63
  "dependencies": {
63
- "@appium/base-driver": "^10.1.2",
64
- "@appium/base-plugin": "^3.0.5",
65
- "@appium/docutils": "^2.2.0",
66
- "@appium/logger": "^2.0.3",
67
- "@appium/schema": "^1.0.0",
68
- "@appium/support": "^7.0.4",
69
- "@appium/types": "^1.1.2",
64
+ "@appium/base-driver": "^10.2.1",
65
+ "@appium/base-plugin": "^3.1.0",
66
+ "@appium/docutils": "^2.2.2",
67
+ "@appium/logger": "^2.0.5",
68
+ "@appium/schema": "^1.1.0",
69
+ "@appium/support": "^7.0.6",
70
+ "@appium/types": "^1.2.1",
70
71
  "@sidvind/better-ajv-errors": "4.0.1",
71
- "ajv": "8.17.1",
72
+ "ajv": "8.18.0",
72
73
  "ajv-formats": "3.0.1",
73
74
  "argparse": "2.0.1",
74
75
  "async-lock": "1.4.1",
75
- "asyncbox": "3.0.0",
76
- "axios": "1.13.2",
76
+ "axios": "1.13.6",
77
77
  "bluebird": "3.7.2",
78
78
  "lilconfig": "3.1.3",
79
- "lodash": "4.17.21",
80
- "lru-cache": "11.2.4",
79
+ "lodash": "4.17.23",
80
+ "lru-cache": "11.2.6",
81
81
  "ora": "5.4.1",
82
82
  "package-changed": "3.0.0",
83
83
  "resolve-from": "5.0.0",
84
- "semver": "7.7.3",
85
- "source-map-support": "0.5.21",
86
- "teen_process": "3.0.4",
87
- "type-fest": "5.3.0",
88
- "winston": "3.18.3",
89
- "wrap-ansi": "7.0.0",
90
- "ws": "8.18.3",
84
+ "semver": "7.7.4",
85
+ "teen_process": "4.0.10",
86
+ "type-fest": "5.4.4",
87
+ "winston": "3.19.0",
88
+ "ws": "8.19.0",
91
89
  "yaml": "2.8.2"
92
90
  },
93
91
  "engines": {
@@ -97,5 +95,5 @@
97
95
  "publishConfig": {
98
96
  "access": "public"
99
97
  },
100
- "gitHead": "9004554879687ddad51d3afdf8c711b027efbd99"
98
+ "gitHead": "980a121804ae006db879fb6860f627ac36174c15"
101
99
  }
@@ -38,12 +38,6 @@ let PLUGIN_TYPE;
38
38
  /** @type {typeof import('../lib/extension').loadExtensions} */
39
39
  let loadExtensions;
40
40
 
41
- const _ = require('lodash');
42
- const wrap = _.partial(
43
- require('wrap-ansi'),
44
- _,
45
- process.stderr.columns ?? process.stdout.columns ?? 80
46
- );
47
41
  const ora = require('ora');
48
42
 
49
43
  /** @type {typeof import('@appium/support').env} */
@@ -54,7 +48,7 @@ let util;
54
48
  let logger;
55
49
 
56
50
  function log(message) {
57
- console.error(wrap(`[Appium] ${message}`));
51
+ console.error(`[Appium] ${message}`);
58
52
  }
59
53
 
60
54
  /**
@@ -118,9 +112,12 @@ async function main() {
118
112
  }).start();
119
113
 
120
114
  if (!driverEnv && !pluginEnv) {
121
- spinner.succeed(
122
- wrap(`No drivers or plugins to automatically install.
123
- 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".`)
115
+ spinner.succeed('No drivers or plugins to automatically install.');
116
+ log(
117
+ 'If desired, provide the argument "--drivers=<driver_name>[,<driver_name>...]" and/or ' +
118
+ '"--plugins=<plugin_name>[,<plugin_name>...]" to the "npm install appium" command. ' +
119
+ 'The specified extensions will be installed automatically alongside Appium. ' +
120
+ 'For a list of known extensions, run "appium <driver|plugin> list".'
124
121
  );
125
122
  return;
126
123
  }
package/tsconfig.json CHANGED
@@ -7,19 +7,22 @@
7
7
  "@appium/support": ["../support"],
8
8
  "@appium/base-driver": ["../base-driver"],
9
9
  "@appium/base-plugin": ["../base-plugin"],
10
+ "@appium/fake-driver": ["../fake-driver"],
10
11
  "@appium/types": ["../types"],
11
12
  "@appium/schema": ["../schema"],
12
13
  "appium": ["."]
13
14
  },
14
- "checkJs": true
15
+ "checkJs": true,
16
+ "types": ["mocha", "chai", "chai-as-promised", "node"]
15
17
  },
16
- "include": ["lib", "types"],
18
+ "include": ["lib", "types", "test", "package.json"],
17
19
  "references": [
18
20
  {"path": "../schema"},
19
21
  {"path": "../types"},
20
22
  {"path": "../support"},
21
23
  {"path": "../base-driver"},
22
24
  {"path": "../base-plugin"},
25
+ {"path": "../fake-driver"},
23
26
  {"path": "../test-support"}
24
27
  ]
25
28
  }
package/types/cli.ts CHANGED
@@ -1,6 +1,6 @@
1
- import {DriverType, PluginType, ServerArgs} from '@appium/types';
2
- import {SetOptional} from 'type-fest';
3
- import {InstallType} from './manifest';
1
+ import type {DriverType, PluginType, ServerArgs} from '@appium/types';
2
+ import type {SetOptional} from 'type-fest';
3
+ import type {InstallType} from './manifest';
4
4
  export type CliCommandServer = 'server';
5
5
  export type CliCommandSetup = 'setup';
6
6
  export type CliCommandDriver = DriverType;
@@ -26,7 +26,7 @@ export type CliCommandSetupSubcommand = 'mobile' | 'browser' | 'desktop' | 'rese
26
26
  * Possible subcommands of {@linkcode CliCommandDriver} or
27
27
  * {@linkcode CliCommandPlugin}.
28
28
  */
29
- export type CliExtensionSubcommand = 'install' | 'list' | 'run' | 'uninstall' | 'update'| 'doctor';
29
+ export type CliExtensionSubcommand = 'install' | 'list' | 'run' | 'uninstall' | 'update' | 'doctor';
30
30
 
31
31
  export interface CliExtensionSubcommandListArgs {
32
32
  showInstalled?: boolean;
package/types/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {ExtensionType, DriverType, DriverClass, PluginType, PluginClass} from '@appium/types';
1
+ import type {ExtensionType, DriverType, DriverClass, PluginType, PluginClass} from '@appium/types';
2
2
 
3
3
  export * from './manifest';
4
4
  export * from './cli';
@@ -1,6 +1,6 @@
1
- import {DriverType, ExtensionType, PluginType} from '@appium/types';
2
- import {SchemaObject} from 'ajv';
3
- import {PackageJson, SetRequired} from 'type-fest';
1
+ import type {DriverType, ExtensionType, PluginType} from '@appium/types';
2
+ import type {SchemaObject} from 'ajv';
3
+ import type {PackageJson, SetRequired} from 'type-fest';
4
4
 
5
5
  /**
6
6
  * One of the possible extension installation stratgies
@@ -1,6 +1,6 @@
1
- import {DriverType, ExtensionType, PluginType} from '@appium/types';
2
- import {SchemaObject} from 'ajv';
3
- import {PackageJson, SetRequired} from 'type-fest';
1
+ import type {DriverType, ExtensionType, PluginType} from '@appium/types';
2
+ import type {SchemaObject} from 'ajv';
3
+ import type {PackageJson, SetRequired} from 'type-fest';
4
4
 
5
5
  /**
6
6
  * One of the possible extension installation stratgies
@@ -1,6 +1,6 @@
1
- import {DriverType, ExtensionType, PluginType} from '@appium/types';
2
- import {SchemaObject} from 'ajv';
3
- import {PackageJson, SetRequired} from 'type-fest';
1
+ import type {DriverType, ExtensionType, PluginType} from '@appium/types';
2
+ import type {SchemaObject} from 'ajv';
3
+ import type {PackageJson, SetRequired} from 'type-fest';
4
4
 
5
5
  /**
6
6
  * One of the possible extension installation stratgies