appium 2.0.0-beta.43 → 2.0.0-beta.44

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/utils.js CHANGED
@@ -2,6 +2,8 @@ import _ from 'lodash';
2
2
  import logger from './logger';
3
3
  import {processCapabilities, PROTOCOLS} from '@appium/base-driver';
4
4
  import {inspect as dump} from 'util';
5
+ import {node} from '@appium/support';
6
+ import path from 'path';
5
7
 
6
8
  const W3C_APPIUM_PREFIX = 'appium';
7
9
 
@@ -209,6 +211,63 @@ function getPackageVersion(pkgName) {
209
211
  return pkgInfo.version;
210
212
  }
211
213
 
214
+ /**
215
+ * Adjusts NODE_PATH environment variable,
216
+ * so drivers and plugins could load their peer dependencies.
217
+ * Read https://nodejs.org/api/modules.html#loading-from-the-global-folders
218
+ * for more details.
219
+ * @returns {void}
220
+ */
221
+ function adjustNodePath() {
222
+ const selfRoot = node.getModuleRootSync('appium', __filename);
223
+ if (!selfRoot || path.dirname(selfRoot).length >= selfRoot.length) {
224
+ return;
225
+ }
226
+ const nodeModulesRoot = path.dirname(selfRoot);
227
+
228
+ const refreshRequirePaths = () => {
229
+ try {
230
+ // ! This hack allows us to avoid modification of import
231
+ // ! statements in client modules. It uses a private API though,
232
+ // ! so it could break (maybe, eventually).
233
+ // See https://gist.github.com/branneman/8048520#7-the-hack
234
+ // @ts-ignore
235
+ require('module').Module._initPaths();
236
+ return true;
237
+ } catch (e) {
238
+ logger.info(`Module init paths cannot be refreshed. Original error: ${e.message}`);
239
+ return false;
240
+ }
241
+ };
242
+
243
+ if (!process.env.NODE_PATH) {
244
+ process.env.NODE_PATH = nodeModulesRoot;
245
+ if (refreshRequirePaths()) {
246
+ logger.info(`Setting NODE_PATH to '${nodeModulesRoot}'`);
247
+ process.env.APPIUM_OMIT_PEER_DEPS = '1';
248
+ } else {
249
+ delete process.env.NODE_PATH;
250
+ }
251
+ return;
252
+ }
253
+
254
+ const nodePathParts = process.env.NODE_PATH.split(path.delimiter);
255
+ if (nodePathParts.includes(nodeModulesRoot)) {
256
+ logger.info(`NODE_PATH already includes '${nodeModulesRoot}'`);
257
+ process.env.APPIUM_OMIT_PEER_DEPS = '1';
258
+ return;
259
+ }
260
+
261
+ nodePathParts.push(nodeModulesRoot);
262
+ process.env.NODE_PATH = nodePathParts.join(path.delimiter);
263
+ if (refreshRequirePaths()) {
264
+ logger.info(`Adding '${nodeModulesRoot}' to NODE_PATH`);
265
+ process.env.APPIUM_OMIT_PEER_DEPS = '1';
266
+ } else {
267
+ process.env.NODE_PATH = _.without(nodePathParts, nodeModulesRoot).join(path.delimiter);
268
+ }
269
+ }
270
+
212
271
  /**
213
272
  * Pulls the initial values of Appium settings from the given capabilities argument.
214
273
  * Each setting item must satisfy the following format:
@@ -250,6 +309,7 @@ export {
250
309
  getPackageVersion,
251
310
  pullSettings,
252
311
  removeAppiumPrefixes,
312
+ adjustNodePath,
253
313
  };
254
314
 
255
315
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium",
3
- "version": "2.0.0-beta.43",
3
+ "version": "2.0.0-beta.44",
4
4
  "description": "Automation for Apps.",
5
5
  "keywords": [
6
6
  "automation",
@@ -37,7 +37,6 @@
37
37
  "driver.*",
38
38
  "support.*",
39
39
  "plugin.*",
40
- "test.*",
41
40
  "scripts/autoinstall-extensions.js",
42
41
  "types"
43
42
  ],
@@ -61,19 +60,18 @@
61
60
  "test:unit": "mocha \"./test/unit/**/*.spec.js\""
62
61
  },
63
62
  "dependencies": {
64
- "@appium/base-driver": "^8.7.0",
65
- "@appium/base-plugin": "^1.10.2",
66
- "@appium/docutils": "^0.0.10",
63
+ "@appium/base-driver": "^8.7.1",
64
+ "@appium/base-plugin": "^1.10.3",
65
+ "@appium/docutils": "^0.0.11",
67
66
  "@appium/schema": "^0.0.9",
68
- "@appium/support": "^2.59.5",
69
- "@appium/test-support": "^1.5.0",
70
- "@appium/types": "^0.4.0",
71
- "@babel/runtime": "7.18.9",
67
+ "@appium/support": "^2.60.0",
68
+ "@appium/types": "^0.4.1",
69
+ "@babel/runtime": "7.19.0",
72
70
  "@sidvind/better-ajv-errors": "2.0.0",
73
71
  "@types/argparse": "2.0.10",
74
72
  "@types/bluebird": "3.5.36",
75
73
  "@types/fancy-log": "2.0.0",
76
- "@types/semver": "7.3.10",
74
+ "@types/semver": "7.3.12",
77
75
  "@types/teen_process": "1.16.1",
78
76
  "@types/wrap-ansi": "3.0.0",
79
77
  "ajv": "8.11.0",
@@ -95,7 +93,7 @@
95
93
  "semver": "7.3.7",
96
94
  "source-map-support": "0.5.21",
97
95
  "teen_process": "1.16.0",
98
- "type-fest": "2.18.0",
96
+ "type-fest": "2.19.0",
99
97
  "winston": "3.8.1",
100
98
  "wrap-ansi": "7.0.0",
101
99
  "yaml": "2.1.1"
@@ -108,5 +106,5 @@
108
106
  "access": "public",
109
107
  "tag": "next"
110
108
  },
111
- "gitHead": "c58f32441daba3aae9768a57d0a412fe92f4b587"
109
+ "gitHead": "c26af8f85230ac65cbc19f08f763942f74b0eb0c"
112
110
  }
package/test.d.ts DELETED
@@ -1,7 +0,0 @@
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 DELETED
@@ -1,13 +0,0 @@
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');