appium 2.0.0-beta.40 → 2.0.0-beta.41

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.
package/lib/config.js CHANGED
@@ -28,15 +28,18 @@ function getNodeVersion() {
28
28
  return /** @type {import('semver').SemVer} */ (semver.coerce(process.version));
29
29
  }
30
30
 
31
+ /**
32
+ * @param {boolean} [useGithubApiFallback]
33
+ */
31
34
  async function updateBuildInfo(useGithubApiFallback = false) {
32
35
  const sha = await getGitRev(useGithubApiFallback);
33
36
  if (!sha) {
34
37
  return;
35
38
  }
36
39
  BUILD_INFO['git-sha'] = sha;
37
- const built = await getGitTimestamp(sha, useGithubApiFallback);
38
- if (built) {
39
- BUILD_INFO.built = built;
40
+ const buildTimestamp = await getGitTimestamp(sha, useGithubApiFallback);
41
+ if (buildTimestamp) {
42
+ BUILD_INFO.built = buildTimestamp;
40
43
  }
41
44
  }
42
45
 
@@ -51,6 +54,10 @@ async function findGitRoot() {
51
54
  return await findUp(GIT_META_ROOT, {cwd: rootDir, type: 'directory'});
52
55
  }
53
56
 
57
+ /**
58
+ * @param {boolean} [useGithubApiFallback]
59
+ * @returns {Promise<string?>}
60
+ */
54
61
  async function getGitRev(useGithubApiFallback = false) {
55
62
  const gitRoot = await findGitRoot();
56
63
  if (gitRoot) {
@@ -66,21 +73,16 @@ async function getGitRev(useGithubApiFallback = false) {
66
73
  return null;
67
74
  }
68
75
 
76
+ // If the package folder is not a valid git repository
77
+ // then fetch the corresponding tag info from GitHub
69
78
  try {
70
- const resBodyObj = (
71
- await axios.get(`${GITHUB_API}/tags`, {
79
+ return (
80
+ await axios.get(`${GITHUB_API}/git/refs/tags/appium@${APPIUM_VER}`, {
72
81
  headers: {
73
82
  'User-Agent': `Appium ${APPIUM_VER}`,
74
83
  },
75
84
  })
76
- ).data;
77
- if (_.isArray(resBodyObj)) {
78
- for (const {name, commit} of resBodyObj) {
79
- if (name === `v${APPIUM_VER}` && commit && commit.sha) {
80
- return commit.sha;
81
- }
82
- }
83
- }
85
+ ).data?.object?.sha;
84
86
  } catch (ign) {}
85
87
  return null;
86
88
  }
@@ -106,21 +108,13 @@ async function getGitTimestamp(commitSha, useGithubApiFallback = false) {
106
108
  }
107
109
 
108
110
  try {
109
- const resBodyObj = (
110
- await axios.get(`${GITHUB_API}/commits/${commitSha}`, {
111
+ return (
112
+ await axios.get(`${GITHUB_API}/git/tags/${commitSha}`, {
111
113
  headers: {
112
114
  'User-Agent': `Appium ${APPIUM_VER}`,
113
115
  },
114
116
  })
115
- ).data;
116
- if (resBodyObj && resBodyObj.commit) {
117
- if (resBodyObj.commit.committer && resBodyObj.commit.committer.date) {
118
- return resBodyObj.commit.committer.date;
119
- }
120
- if (resBodyObj.commit.author && resBodyObj.commit.author.date) {
121
- return resBodyObj.commit.author.date;
122
- }
123
- }
117
+ ).data?.tagger?.date;
124
118
  } catch (ign) {}
125
119
  return null;
126
120
  }
@@ -203,11 +203,9 @@ export class ExtensionConfig {
203
203
 
204
204
  if (!_.isEmpty(errorSummaries)) {
205
205
  log.error(
206
- `Appium encountered ${util.pluralize(
207
- 'error',
208
- errorSummaries.length,
209
- true
210
- )} while validating ${this.configKey} found in manifest ${this.manifestPath}`
206
+ `Appium encountered ${util.pluralize('error', errorMap.size, true)} while validating ${
207
+ this.configKey
208
+ } found in manifest ${this.manifestPath}`
211
209
  );
212
210
  for (const summary of errorSummaries) {
213
211
  log.error(summary);
@@ -219,7 +217,7 @@ export class ExtensionConfig {
219
217
  log.warn(
220
218
  `Appium encountered ${util.pluralize(
221
219
  'warning',
222
- warningSummaries.length,
220
+ warningMap.size,
223
221
  true
224
222
  )} while validating ${this.configKey} found in manifest ${this.manifestPath}`
225
223
  );
package/lib/main.js CHANGED
@@ -4,7 +4,7 @@ import {init as logsinkInit} from './logsink'; // this import needs to come firs
4
4
  import logger from './logger'; // logger needs to remain second
5
5
  // @ts-ignore
6
6
  import {routeConfiguringFunction as makeRouter, server as baseServer} from '@appium/base-driver';
7
- import {logger as logFactory, util, env} from '@appium/support';
7
+ import {logger as logFactory, util, env, fs} from '@appium/support';
8
8
  import {asyncify} from 'asyncbox';
9
9
  import _ from 'lodash';
10
10
  import {AppiumDriver} from './appium';
@@ -15,6 +15,7 @@ import {
15
15
  checkNodeOk,
16
16
  getGitRev,
17
17
  getNonDefaultServerArgs,
18
+ rootDir,
18
19
  showConfig,
19
20
  showBuildInfo,
20
21
  validateTmpDir,
@@ -26,8 +27,9 @@ import {DRIVER_TYPE, PLUGIN_TYPE, SERVER_SUBCOMMAND} from './constants';
26
27
  import registerNode from './grid-register';
27
28
  import {getDefaultsForSchema, validate} from './schema/schema';
28
29
  import {inspect} from './utils';
30
+ import path from 'path';
29
31
 
30
- const {resolveAppiumHome} = env;
32
+ const {resolveAppiumHome, hasAppiumDependency} = env;
31
33
 
32
34
  /**
33
35
  *
@@ -170,6 +172,19 @@ function areServerCommandArgs(args) {
170
172
  async function init(args) {
171
173
  const appiumHome = args?.appiumHome ?? (await resolveAppiumHome());
172
174
 
175
+ // this is here so extensions installed in e.g., `~/.appium` can find the peer dependency
176
+ // of `appium`, which lives wherever it lives (see `rootDir`).
177
+ if (!(await hasAppiumDependency(appiumHome))) {
178
+ try {
179
+ await fs.mkdirp(path.join(appiumHome, 'node_modules'));
180
+ await fs.symlink(rootDir, path.join(appiumHome, 'node_modules', 'appium'), 'junction');
181
+ } catch (err) {
182
+ if (err.code !== 'EEXIST') {
183
+ throw new Error(`Unable to create symlink to appium: ${err.message}`);
184
+ }
185
+ }
186
+ }
187
+
173
188
  const {driverConfig, pluginConfig} = await loadExtensions(appiumHome);
174
189
 
175
190
  const parser = getParser();
@@ -225,5 +225,5 @@ export class ArgSpec {
225
225
  */
226
226
 
227
227
  /**
228
- * @typedef {import('../extension/manifest').ExtensionType} ExtensionType
228
+ * @typedef {import('@appium/types').ExtensionType} ExtensionType
229
229
  */
@@ -680,7 +680,7 @@ export const {isAllowedSchemaFileExtension} = AppiumSchema;
680
680
  */
681
681
 
682
682
  /**
683
- * @typedef {import('../extension/manifest').ExtensionType} ExtensionType
683
+ * @typedef {import('@appium/types').ExtensionType} ExtensionType
684
684
  */
685
685
 
686
686
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium",
3
- "version": "2.0.0-beta.40",
3
+ "version": "2.0.0-beta.41",
4
4
  "description": "Automation for Apps.",
5
5
  "keywords": [
6
6
  "automation",
@@ -49,33 +49,42 @@
49
49
  "dev:docs": "npm run build:docs:assets && npm run dev:docs:en",
50
50
  "dev:docs:en": "mkdocs serve -f ./docs/mkdocs-en.yml",
51
51
  "dev:docs:ja": "mkdocs serve -f ./docs/mkdocs-ja.yml",
52
+ "dev:docs:zh": "mkdocs serve -f ./docs/mkdocs-zh.yml",
52
53
  "fix": "npm run lint -- --fix",
53
54
  "postinstall": "node ./scripts/autoinstall-extensions.js",
54
55
  "lint": "eslint -c ../../.eslintrc --ignore-path ../../.eslintignore .",
55
56
  "prepare": "npm run build",
56
57
  "publish:docs": "APPIUM_DOCS_PUBLISH=1 npm run build:docs",
57
58
  "test": "npm run test:unit",
58
- "test:e2e": "mocha --timeout 75s --slow 30s \"./test/e2e/**/*.spec.js\"",
59
+ "test:e2e": "mocha --timeout 1m --slow 30s \"./test/e2e/**/*.spec.js\"",
60
+ "test:smoke": "node ./index.js --show-build-info",
59
61
  "test:unit": "mocha \"./test/unit/**/*.spec.js\""
60
62
  },
61
63
  "dependencies": {
62
- "@appium/base-driver": "^8.5.7",
63
- "@appium/base-plugin": "^1.9.2",
64
- "@appium/docutils": "^0.0.7",
65
- "@appium/schema": "^0.0.7",
66
- "@appium/support": "^2.59.2",
67
- "@appium/test-support": "^1.3.22",
68
- "@babel/runtime": "7.18.3",
64
+ "@appium/base-driver": "^8.6.0",
65
+ "@appium/base-plugin": "^1.10.0",
66
+ "@appium/docutils": "^0.0.8",
67
+ "@appium/schema": "^0.0.8",
68
+ "@appium/support": "^2.59.3",
69
+ "@appium/test-support": "^1.4.0",
70
+ "@appium/types": "^0.3.0",
71
+ "@babel/runtime": "7.18.9",
69
72
  "@sidvind/better-ajv-errors": "2.0.0",
73
+ "@types/argparse": "2.0.10",
74
+ "@types/bluebird": "3.5.36",
75
+ "@types/fancy-log": "2.0.0",
76
+ "@types/semver": "7.3.10",
77
+ "@types/teen_process": "1.16.1",
78
+ "@types/wrap-ansi": "3.0.0",
70
79
  "ajv": "8.11.0",
71
80
  "ajv-formats": "2.1.1",
72
81
  "argparse": "2.0.1",
73
- "async-lock": "1.3.1",
82
+ "async-lock": "1.3.2",
74
83
  "asyncbox": "2.9.2",
75
84
  "axios": "0.27.2",
76
85
  "bluebird": "3.7.2",
77
86
  "find-up": "5.0.0",
78
- "lilconfig": "2.0.5",
87
+ "lilconfig": "2.0.6",
79
88
  "lodash": "4.17.21",
80
89
  "longjohn": "0.2.12",
81
90
  "npmlog": "6.0.2",
@@ -84,10 +93,10 @@
84
93
  "resolve-from": "5.0.0",
85
94
  "semver": "7.3.7",
86
95
  "source-map-support": "0.5.21",
87
- "supports-color": "8.1.1",
88
96
  "teen_process": "1.16.0",
89
- "winston": "3.7.2",
90
- "word-wrap": "1.2.3",
97
+ "type-fest": "2.17.0",
98
+ "winston": "3.8.1",
99
+ "wrap-ansi": "7.0.0",
91
100
  "yaml": "2.1.1"
92
101
  },
93
102
  "engines": {
@@ -98,5 +107,5 @@
98
107
  "access": "public",
99
108
  "tag": "next"
100
109
  },
101
- "gitHead": "4cf2cc92d066ed32adda27e0439547290a4b71ce"
110
+ "gitHead": "f6e6d7234e7fe92f989f4e37a71007044985dedf"
102
111
  }
@@ -28,11 +28,17 @@ let PLUGIN_TYPE;
28
28
  let loadExtensions;
29
29
 
30
30
  const {env, util, logger} = require('@appium/support');
31
+ const _ = require('lodash');
32
+ const wrap = _.partial(
33
+ require('wrap-ansi'),
34
+ _,
35
+ process.stderr.columns ?? process.stdout.columns ?? 25
36
+ );
31
37
 
32
38
  const ora = require('ora');
33
39
 
34
40
  const log = (message) => {
35
- console.error(`[Appium] ${message}`);
41
+ console.error(wrap(`[Appium] ${message}`));
36
42
  };
37
43
 
38
44
  const spinner = ora({
@@ -59,7 +65,8 @@ try {
59
65
  }
60
66
 
61
67
  async function main() {
62
- if (await env.hasAppiumDependency()) {
68
+ // if we're doing `npm install -g appium` then we will assume we don't have a local appium.
69
+ if (!process.env.npm_config_global && (await env.hasAppiumDependency())) {
63
70
  log(`Found local Appium installation; skipping automatic installation of extensions.`);
64
71
  return;
65
72
  }
@@ -74,7 +81,8 @@ async function main() {
74
81
 
75
82
  if (!driverEnv && !pluginEnv) {
76
83
  spinner.succeed(
77
- 'No drivers or plugins to automatically install. If desired, provide arguments with comma-separated values "--drivers=<known_driver>[,known_driver...]" and/or "--plugins=<known_plugin>[,known_plugin...]" to the "npm install appium" command. The specified extensions will be installed automatically with Appium. Note: to see the list of known extensions, run "appium <driver|plugin> list".'
84
+ wrap(`No drivers or plugins to automatically install.
85
+ If desired, provide arguments with comma-separated values "--drivers=<known_driver>[,known_driver...]" and/or "--plugins=<known_plugin>[,known_plugin...]" to the "npm install appium" command. The specified extensions will be installed automatically with Appium. Note: to see the list of known extensions, run "appium <driver|plugin> list".`)
78
86
  );
79
87
  return;
80
88
  }
package/test.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export * from '@appium/test-support';
2
+ /**
3
+ * @typedef {import('@appium/test-support').SessionHelpers} SessionHelpers
4
+ */
5
+ /**
6
+ * @typedef {import('@appium/test-support').E2ESetupOpts} E2ESetupOpts
7
+ */
package/test.js ADDED
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ // @ts-check
4
+
5
+ /**
6
+ * This module is here to re-export `@appium/test-support` for Appium extensions.
7
+ *
8
+ * @see https://npm.im/@appium/test-support
9
+ * @example
10
+ * const { getPort } = require('appium/test');
11
+ */
12
+
13
+ module.exports = require('@appium/test-support');
package/types/cli.ts CHANGED
@@ -1,18 +1,7 @@
1
1
  import {ServerArgs} from '@appium/types';
2
- import type {
3
- DRIVER_TYPE as DRIVER_SUBCOMMAND,
4
- EXT_SUBCOMMAND_INSTALL,
5
- EXT_SUBCOMMAND_LIST,
6
- EXT_SUBCOMMAND_RUN,
7
- EXT_SUBCOMMAND_UNINSTALL,
8
- EXT_SUBCOMMAND_UPDATE,
9
- PLUGIN_TYPE as PLUGIN_SUBCOMMAND,
10
- SERVER_SUBCOMMAND,
11
- } from '../lib/constants';
12
-
13
- export type ServerSubcommand = typeof SERVER_SUBCOMMAND;
14
- export type DriverSubcommand = typeof DRIVER_SUBCOMMAND;
15
- export type PluginSubcommand = typeof PLUGIN_SUBCOMMAND;
2
+ export type ServerSubcommand = 'server';
3
+ export type DriverSubcommand = 'driver';
4
+ export type PluginSubcommand = 'plugin';
16
5
 
17
6
  /**
18
7
  * Possible subcommands for the `appium` CLI.
@@ -24,11 +13,11 @@ export type CliSubcommand = ServerSubcommand | DriverSubcommand | PluginSubcomma
24
13
  * {@linkcode PluginSubcommand}.
25
14
  */
26
15
  export type CliExtensionSubcommand =
27
- | typeof EXT_SUBCOMMAND_INSTALL
28
- | typeof EXT_SUBCOMMAND_LIST
29
- | typeof EXT_SUBCOMMAND_RUN
30
- | typeof EXT_SUBCOMMAND_UPDATE
31
- | typeof EXT_SUBCOMMAND_UNINSTALL;
16
+ | 'install'
17
+ | 'list'
18
+ | 'run'
19
+ | 'uninstall'
20
+ | 'update';
32
21
 
33
22
  /**
34
23
  * Random stuff that may appear in the parsed args which has no equivalent in a