appium 2.0.0-beta.35 → 2.0.0-beta.37

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 (122) hide show
  1. package/build/lib/appium.d.ts +41 -52
  2. package/build/lib/appium.d.ts.map +1 -1
  3. package/build/lib/appium.js +32 -15
  4. package/build/lib/cli/args.d.ts +1 -1
  5. package/build/lib/cli/args.d.ts.map +1 -1
  6. package/build/lib/cli/args.js +1 -1
  7. package/build/lib/cli/driver-command.d.ts +3 -3
  8. package/build/lib/cli/driver-command.d.ts.map +1 -1
  9. package/build/lib/cli/driver-command.js +1 -1
  10. package/build/lib/cli/extension-command.d.ts +60 -38
  11. package/build/lib/cli/extension-command.d.ts.map +1 -1
  12. package/build/lib/cli/extension-command.js +115 -59
  13. package/build/lib/cli/extension.d.ts +9 -5
  14. package/build/lib/cli/extension.d.ts.map +1 -1
  15. package/build/lib/cli/extension.js +5 -7
  16. package/build/lib/cli/parser.d.ts +3 -3
  17. package/build/lib/cli/parser.d.ts.map +1 -1
  18. package/build/lib/cli/parser.js +1 -1
  19. package/build/lib/cli/plugin-command.d.ts +1 -1
  20. package/build/lib/cli/plugin-command.d.ts.map +1 -1
  21. package/build/lib/cli/plugin-command.js +1 -1
  22. package/build/lib/cli/utils.js +1 -1
  23. package/build/lib/config-file.d.ts.map +1 -1
  24. package/build/lib/config-file.js +1 -1
  25. package/build/lib/config.d.ts +4 -4
  26. package/build/lib/config.d.ts.map +1 -1
  27. package/build/lib/config.js +1 -1
  28. package/build/lib/constants.d.ts.map +1 -1
  29. package/build/lib/constants.js +1 -1
  30. package/build/lib/extension/driver-config.d.ts +29 -32
  31. package/build/lib/extension/driver-config.d.ts.map +1 -1
  32. package/build/lib/extension/driver-config.js +7 -20
  33. package/build/lib/extension/extension-config.d.ts +108 -36
  34. package/build/lib/extension/extension-config.d.ts.map +1 -1
  35. package/build/lib/extension/extension-config.js +199 -60
  36. package/build/lib/extension/index.d.ts +16 -7
  37. package/build/lib/extension/index.d.ts.map +1 -1
  38. package/build/lib/extension/index.js +15 -18
  39. package/build/lib/extension/manifest.d.ts +12 -12
  40. package/build/lib/extension/manifest.d.ts.map +1 -1
  41. package/build/lib/extension/manifest.js +13 -3
  42. package/build/lib/extension/package-changed.d.ts.map +1 -1
  43. package/build/lib/extension/package-changed.js +1 -1
  44. package/build/lib/extension/plugin-config.d.ts +19 -24
  45. package/build/lib/extension/plugin-config.d.ts.map +1 -1
  46. package/build/lib/extension/plugin-config.js +9 -18
  47. package/build/lib/grid-register.d.ts.map +1 -1
  48. package/build/lib/grid-register.js +1 -1
  49. package/build/lib/logger.d.ts +1 -1
  50. package/build/lib/logger.d.ts.map +1 -1
  51. package/build/lib/logger.js +1 -1
  52. package/build/lib/logsink.d.ts.map +1 -1
  53. package/build/lib/logsink.js +3 -2
  54. package/build/lib/main.d.ts +13 -12
  55. package/build/lib/main.d.ts.map +1 -1
  56. package/build/lib/main.js +4 -4
  57. package/build/lib/schema/arg-spec.d.ts +4 -4
  58. package/build/lib/schema/arg-spec.d.ts.map +1 -1
  59. package/build/lib/schema/arg-spec.js +1 -1
  60. package/build/lib/schema/cli-args.d.ts.map +1 -1
  61. package/build/lib/schema/cli-args.js +1 -1
  62. package/build/lib/schema/cli-transformers.d.ts.map +1 -1
  63. package/build/lib/schema/cli-transformers.js +1 -1
  64. package/build/lib/schema/keywords.d.ts.map +1 -1
  65. package/build/lib/schema/keywords.js +1 -1
  66. package/build/lib/schema/schema.d.ts +2 -2
  67. package/build/lib/schema/schema.d.ts.map +1 -1
  68. package/build/lib/schema/schema.js +1 -1
  69. package/build/lib/utils.d.ts.map +1 -1
  70. package/build/lib/utils.js +1 -1
  71. package/build/tsconfig.tsbuildinfo +1 -1
  72. package/build/types/appium-manifest.d.ts +23 -4
  73. package/build/types/appium-manifest.d.ts.map +1 -1
  74. package/build/types/cli.d.ts.map +1 -1
  75. package/build/types/{external-manifest.d.ts → extension-manifest.d.ts} +15 -7
  76. package/build/types/extension-manifest.d.ts.map +1 -0
  77. package/build/types/index.d.ts +6 -5
  78. package/build/types/index.d.ts.map +1 -1
  79. package/driver.d.ts +1 -0
  80. package/driver.js +14 -0
  81. package/lib/appium.js +208 -124
  82. package/lib/cli/args.js +143 -93
  83. package/lib/cli/driver-command.js +10 -15
  84. package/lib/cli/extension-command.js +226 -175
  85. package/lib/cli/extension.js +15 -19
  86. package/lib/cli/parser.js +19 -31
  87. package/lib/cli/plugin-command.js +8 -8
  88. package/lib/cli/utils.js +8 -14
  89. package/lib/config-file.js +21 -25
  90. package/lib/config.js +82 -64
  91. package/lib/constants.js +4 -13
  92. package/lib/extension/driver-config.js +171 -171
  93. package/lib/extension/extension-config.js +347 -126
  94. package/lib/extension/index.js +72 -58
  95. package/lib/extension/manifest.js +48 -57
  96. package/lib/extension/package-changed.js +9 -8
  97. package/lib/extension/plugin-config.js +62 -62
  98. package/lib/grid-register.js +29 -18
  99. package/lib/logger.js +1 -2
  100. package/lib/logsink.js +29 -31
  101. package/lib/main.js +111 -73
  102. package/lib/schema/arg-spec.js +10 -13
  103. package/lib/schema/cli-args.js +14 -37
  104. package/lib/schema/cli-transformers.js +7 -14
  105. package/lib/schema/keywords.js +15 -13
  106. package/lib/schema/schema.js +58 -75
  107. package/lib/utils.js +50 -25
  108. package/package.json +25 -18
  109. package/plugin.d.ts +1 -0
  110. package/plugin.js +13 -0
  111. package/scripts/autoinstall-extensions.js +177 -0
  112. package/support.d.ts +1 -0
  113. package/support.js +13 -0
  114. package/types/appium-manifest.ts +27 -15
  115. package/types/cli.ts +2 -9
  116. package/types/{external-manifest.ts → extension-manifest.ts} +21 -15
  117. package/types/index.ts +12 -5
  118. package/build/types/extension.d.ts +0 -43
  119. package/build/types/extension.d.ts.map +0 -1
  120. package/build/types/external-manifest.d.ts.map +0 -1
  121. package/scripts/postinstall.js +0 -71
  122. package/types/extension.ts +0 -56
@@ -1,10 +1,10 @@
1
-
2
1
  import _ from 'lodash';
3
- import { USE_ALL_PLUGINS } from '../constants';
2
+ import {USE_ALL_PLUGINS} from '../constants';
4
3
  import log from '../logger';
5
- import { DriverConfig } from './driver-config';
6
- import { Manifest } from './manifest';
7
- import { PluginConfig } from './plugin-config';
4
+ import {DriverConfig} from './driver-config';
5
+ import {Manifest} from './manifest';
6
+ import {PluginConfig} from './plugin-config';
7
+ import B from 'bluebird';
8
8
 
9
9
  /**
10
10
  * Loads extensions and creates `ExtensionConfig` instances.
@@ -17,15 +17,13 @@ import { PluginConfig } from './plugin-config';
17
17
  * @param {string} appiumHome
18
18
  * @returns {Promise<ExtensionConfigs>}
19
19
  */
20
- export async function loadExtensions (appiumHome) {
20
+ export async function loadExtensions(appiumHome) {
21
21
  const manifest = Manifest.getInstance(appiumHome);
22
- const {drivers, plugins} = await manifest.read();
23
- const driverConfig =
24
- DriverConfig.getInstance(manifest) ??
25
- DriverConfig.create(manifest, {extData: drivers});
26
- const pluginConfig =
27
- PluginConfig.getInstance(manifest) ??
28
- PluginConfig.create(manifest, {extData: plugins});
22
+ await manifest.read();
23
+ const driverConfig = DriverConfig.getInstance(manifest) ?? DriverConfig.create(manifest);
24
+ const pluginConfig = PluginConfig.getInstance(manifest) ?? PluginConfig.create(manifest);
25
+
26
+ await B.all([driverConfig.validate(), pluginConfig.validate()]);
29
27
  return {driverConfig, pluginConfig};
30
28
  }
31
29
 
@@ -37,31 +35,31 @@ export async function loadExtensions (appiumHome) {
37
35
  *
38
36
  * @param {import('./plugin-config').PluginConfig} pluginConfig - a plugin extension config
39
37
  * @param {string[]} usePlugins
40
- * @returns {import('../../types').PluginClass[]}
38
+ * @returns {PluginNameMap} Mapping of PluginClass to name
41
39
  */
42
- export function getActivePlugins (pluginConfig, usePlugins = []) {
43
- return _.compact(
44
- Object.keys(pluginConfig.installedExtensions)
45
- .filter(
46
- (pluginName) =>
47
- _.includes(usePlugins, pluginName) ||
48
- (usePlugins.length === 1 && usePlugins[0] === USE_ALL_PLUGINS),
49
- )
50
- .map((pluginName) => {
51
- try {
52
- log.info(`Attempting to load plugin ${pluginName}...`);
53
- const PluginClass = pluginConfig.require(pluginName);
54
-
55
- PluginClass.pluginName = pluginName; // store the plugin name on the class so it can be used later
56
- return PluginClass;
57
- } catch (err) {
58
- log.error(
59
- `Could not load plugin '${pluginName}', so it will not be available. Error ` +
60
- `in loading the plugin was: ${err.message}`,
61
- );
62
- log.debug(err.stack);
63
- }
64
- }),
40
+ export function getActivePlugins(pluginConfig, usePlugins = []) {
41
+ return new Map(
42
+ _.compact(
43
+ Object.keys(pluginConfig.installedExtensions)
44
+ .filter(
45
+ (pluginName) =>
46
+ _.includes(usePlugins, pluginName) ||
47
+ (usePlugins.length === 1 && usePlugins[0] === USE_ALL_PLUGINS)
48
+ )
49
+ .map((pluginName) => {
50
+ try {
51
+ log.info(`Attempting to load plugin ${pluginName}...`);
52
+ const PluginClass = pluginConfig.require(pluginName);
53
+ return [PluginClass, pluginName];
54
+ } catch (err) {
55
+ log.error(
56
+ `Could not load plugin '${pluginName}', so it will not be available. Error ` +
57
+ `in loading the plugin was: ${err.message}`
58
+ );
59
+ log.debug(err.stack);
60
+ }
61
+ })
62
+ )
65
63
  );
66
64
  }
67
65
 
@@ -72,31 +70,47 @@ export function getActivePlugins (pluginConfig, usePlugins = []) {
72
70
  *
73
71
  * @param {import('./driver-config').DriverConfig} driverConfig - a driver extension config
74
72
  * @param {string[]} [useDrivers] - optional list of drivers to load
73
+ * @returns {DriverNameMap}
75
74
  */
76
- export function getActiveDrivers (driverConfig, useDrivers = []) {
77
- return _.compact(
78
- Object.keys(driverConfig.installedExtensions)
79
- .filter(
80
- (driverName) =>
81
- _.includes(useDrivers, driverName) || useDrivers.length === 0,
82
- )
83
- .map((driverName) => {
84
- try {
85
- log.info(`Attempting to load driver ${driverName}...`);
86
- return driverConfig.require(driverName);
87
- } catch (err) {
88
- log.error(
89
- `Could not load driver '${driverName}', so it will not be available. Error ` +
90
- `in loading the driver was: ${err.message}`,
91
- );
92
- log.debug(err.stack);
93
- }
94
- }),
75
+ export function getActiveDrivers(driverConfig, useDrivers = []) {
76
+ return new Map(
77
+ _.compact(
78
+ Object.keys(driverConfig.installedExtensions)
79
+ .filter((driverName) => _.includes(useDrivers, driverName) || useDrivers.length === 0)
80
+ .map((driverName) => {
81
+ try {
82
+ log.info(`Attempting to load driver ${driverName}...`);
83
+ const DriverClass = driverConfig.require(driverName);
84
+ return [DriverClass, driverName];
85
+ } catch (err) {
86
+ log.error(
87
+ `Could not load driver '${driverName}', so it will not be available. Error ` +
88
+ `in loading the driver was: ${err.message}`
89
+ );
90
+ log.debug(err.stack);
91
+ }
92
+ })
93
+ )
95
94
  );
96
95
  }
97
96
 
97
+ /**
98
+ * A mapping of {@linkcode PluginClass} classes to their names.
99
+ * @typedef {Map<PluginClass,string>} PluginNameMap
100
+ */
101
+
102
+ /**
103
+ * A mapping of {@linkcode DriverClass} classes to their names.
104
+ * @typedef {Map<DriverClass,string>} DriverNameMap
105
+ */
106
+
107
+ /**
108
+ * @typedef {import('@appium/types').PluginClass} PluginClass
109
+ * @typedef {import('@appium/types').DriverClass} DriverClass
110
+ */
111
+
98
112
  /**
99
113
  * @typedef ExtensionConfigs
100
- * @property {DriverConfig} driverConfig
101
- * @property {PluginConfig} pluginConfig
114
+ * @property {import('./driver-config').DriverConfig} driverConfig
115
+ * @property {import('./plugin-config').PluginConfig} pluginConfig
102
116
  */
@@ -2,14 +2,14 @@
2
2
  * Module containing {@link Manifest} which handles reading & writing of extension config files.
3
3
  */
4
4
 
5
- import { env, fs } from '@appium/support';
5
+ import {env, fs} from '@appium/support';
6
6
  import _ from 'lodash';
7
7
  import path from 'path';
8
8
  import YAML from 'yaml';
9
- import { DRIVER_TYPE, PLUGIN_TYPE } from '../constants';
9
+ import {DRIVER_TYPE, PLUGIN_TYPE} from '../constants';
10
10
  import log from '../logger';
11
- import { INSTALL_TYPE_NPM } from './extension-config';
12
- import { packageDidChange } from './package-changed';
11
+ import {INSTALL_TYPE_NPM} from './extension-config';
12
+ import {packageDidChange} from './package-changed';
13
13
 
14
14
  /**
15
15
  * Default depth to search in directory tree for whatever it is we're looking for.
@@ -61,7 +61,7 @@ const INITIAL_MANIFEST_DATA = Object.freeze({
61
61
  * @param {any} value
62
62
  * @returns {value is ExtPackageJson<ExtensionType>}
63
63
  */
64
- function isExtension (value) {
64
+ function isExtension(value) {
65
65
  return (
66
66
  _.isPlainObject(value) &&
67
67
  _.isPlainObject(value.appium) &&
@@ -77,7 +77,7 @@ function isExtension (value) {
77
77
  * @param {any} value - Value to test
78
78
  * @returns {value is ExtPackageJson<DriverType>}
79
79
  */
80
- function isDriver (value) {
80
+ function isDriver(value) {
81
81
  return (
82
82
  isExtension(value) &&
83
83
  _.isString(_.get(value, 'appium.driverName')) &&
@@ -93,7 +93,7 @@ function isDriver (value) {
93
93
  * @param {any} value - Value to test
94
94
  * @returns {value is ExtPackageJson<PluginType>}
95
95
  */
96
- function isPlugin (value) {
96
+ function isPlugin(value) {
97
97
  return isExtension(value) && _.isString(_.get(value, 'appium.pluginName'));
98
98
  }
99
99
 
@@ -157,7 +157,7 @@ export class Manifest {
157
157
  * @param {string} appiumHome
158
158
  * @private
159
159
  */
160
- constructor (appiumHome) {
160
+ constructor(appiumHome) {
161
161
  this._appiumHome = appiumHome;
162
162
  this._data = _.cloneDeep(INITIAL_MANIFEST_DATA);
163
163
  }
@@ -169,9 +169,7 @@ export class Manifest {
169
169
  * @param {string} appiumHome - Path to `APPIUM_HOME`
170
170
  * @returns {Manifest}
171
171
  */
172
- static getInstance = _.memoize(function _getInstance (
173
- appiumHome,
174
- ) {
172
+ static getInstance = _.memoize(function _getInstance(appiumHome) {
175
173
  return new Manifest(appiumHome);
176
174
  });
177
175
 
@@ -180,24 +178,18 @@ export class Manifest {
180
178
  * @param {SyncWithInstalledExtensionsOpts} opts
181
179
  * @returns {Promise<boolean>} `true` if any extensions were added, `false` otherwise.
182
180
  */
183
- async syncWithInstalledExtensions ({depthLimit = DEFAULT_SEARCH_DEPTH} = {}) {
181
+ async syncWithInstalledExtensions({depthLimit = DEFAULT_SEARCH_DEPTH} = {}) {
184
182
  const walkOpts = _.defaults({depthLimit}, DEFAULT_FIND_EXTENSIONS_OPTS);
185
183
  // this could be parallelized, but we can't use fs.walk as an async iterator
186
184
  let didChange = false;
187
- for await (const {stats, path: filepath} of fs.walk(
188
- this._appiumHome,
189
- walkOpts,
190
- )) {
185
+ for await (const {stats, path: filepath} of fs.walk(this._appiumHome, walkOpts)) {
191
186
  if (filepath !== this._appiumHome && stats.isDirectory()) {
192
187
  try {
193
188
  const pkg = await env.readPackageInDir(filepath);
194
189
  if (pkg && isExtension(pkg)) {
195
190
  // it's possible that this extension already exists in the manifest,
196
191
  // so only update `didChange` if it's new.
197
- const added = this.addExtensionFromPackage(
198
- pkg,
199
- path.join(filepath, 'package.json'),
200
- );
192
+ const added = this.addExtensionFromPackage(pkg, path.join(filepath, 'package.json'));
201
193
  didChange = didChange || added;
202
194
  }
203
195
  } catch {}
@@ -211,7 +203,7 @@ export class Manifest {
211
203
  * @param {string} name - Driver name
212
204
  * @returns {boolean}
213
205
  */
214
- hasDriver (name) {
206
+ hasDriver(name) {
215
207
  return Boolean(this._data.drivers[name]);
216
208
  }
217
209
 
@@ -220,7 +212,7 @@ export class Manifest {
220
212
  * @param {string} name - Plugin name
221
213
  * @returns {boolean}
222
214
  */
223
- hasPlugin (name) {
215
+ hasPlugin(name) {
224
216
  return Boolean(this._data.plugins[name]);
225
217
  }
226
218
 
@@ -233,13 +225,16 @@ export class Manifest {
233
225
  * @param {string} pkgPath
234
226
  * @returns {boolean} - `true` upon success, `false` if the extension is already registered.
235
227
  */
236
- addExtensionFromPackage (pkgJson, pkgPath) {
228
+ addExtensionFromPackage(pkgJson, pkgPath) {
229
+ const extensionPath = path.dirname(pkgPath);
230
+
237
231
  /**
238
232
  * @type {InternalMetadata}
239
233
  */
240
234
  const internal = {
241
235
  pkgName: pkgJson.name,
242
236
  version: pkgJson.version,
237
+ appiumVersion: pkgJson.peerDependencies?.appium,
243
238
  installType: INSTALL_TYPE_NPM,
244
239
  installSpec: `${pkgJson.name}@${pkgJson.version}`,
245
240
  };
@@ -248,7 +243,7 @@ export class Manifest {
248
243
  if (!this.hasDriver(pkgJson.appium.driverName)) {
249
244
  this.addExtension(DRIVER_TYPE, pkgJson.appium.driverName, {
250
245
  ..._.omit(pkgJson.appium, 'driverName'),
251
- ...internal
246
+ ...internal,
252
247
  });
253
248
  return true;
254
249
  }
@@ -264,9 +259,7 @@ export class Manifest {
264
259
  return false;
265
260
  } else {
266
261
  throw new TypeError(
267
- `The extension in ${path.dirname(
268
- pkgPath,
269
- )} is neither a valid driver nor a valid plugin.`,
262
+ `The extension in ${extensionPath} is neither a valid driver nor a valid plugin.`
270
263
  );
271
264
  }
272
265
  }
@@ -280,23 +273,25 @@ export class Manifest {
280
273
  * @param {ExtType} extType - `driver` or `plugin`
281
274
  * @param {string} extName - Name of extension
282
275
  * @param {ExtManifest<ExtType>} extData - Extension metadata
283
- * @returns {void}
276
+ * @returns {ExtManifest<ExtType>} A clone of `extData`, potentially with a mutated `appiumVersion` field
284
277
  */
285
- addExtension (extType, extName, extData) {
286
- this._data[`${extType}s`][extName] = extData;
278
+ addExtension(extType, extName, extData) {
279
+ const data = _.clone(extData);
280
+ this._data[`${extType}s`][extName] = data;
281
+ return data;
287
282
  }
288
283
 
289
284
  /**
290
285
  * Returns the APPIUM_HOME path
291
286
  */
292
- get appiumHome () {
287
+ get appiumHome() {
293
288
  return this._appiumHome;
294
289
  }
295
290
 
296
291
  /**
297
292
  * Returns the path to the manifest file
298
293
  */
299
- get manifestPath () {
294
+ get manifestPath() {
300
295
  return this._manifestPath;
301
296
  }
302
297
 
@@ -307,7 +302,7 @@ export class Manifest {
307
302
  * @param {ExtType} extType
308
303
  * @returns {ExtRecord<ExtType>}
309
304
  */
310
- getExtensionData (extType) {
305
+ getExtensionData(extType) {
311
306
  return this._data[/** @type {string} */ (`${extType}s`)];
312
307
  }
313
308
 
@@ -321,7 +316,7 @@ export class Manifest {
321
316
  * Only one read operation should happen at a time. This is controlled via the {@link Manifest._reading} property.
322
317
  * @returns {Promise<ManifestData>} The data
323
318
  */
324
- async read () {
319
+ async read() {
325
320
  if (this._reading) {
326
321
  await this._reading;
327
322
  return this._data;
@@ -336,6 +331,7 @@ export class Manifest {
336
331
  log.debug(`Reading ${this._manifestPath}...`);
337
332
  const yaml = await fs.readFile(this._manifestPath, 'utf8');
338
333
  data = YAML.parse(yaml);
334
+ log.debug(`Parsed manifest file: ${JSON.stringify(data, null, 2)}`);
339
335
  } catch (err) {
340
336
  if (err.code === 'ENOENT') {
341
337
  data = _.cloneDeep(INITIAL_MANIFEST_DATA);
@@ -344,11 +340,11 @@ export class Manifest {
344
340
  if (this._manifestPath) {
345
341
  throw new Error(
346
342
  `Appium had trouble loading the extension installation ` +
347
- `cache file (${this._manifestPath}). It may be invalid YAML. Specific error: ${err.message}`,
343
+ `cache file (${this._manifestPath}). It may be invalid YAML. Specific error: ${err.message}`
348
344
  );
349
345
  } else {
350
346
  throw new Error(
351
- `Appium encountered an unknown problem. Specific error: ${err.message}`,
347
+ `Appium encountered an unknown problem. Specific error: ${err.message}`
352
348
  );
353
349
  }
354
350
  }
@@ -357,7 +353,7 @@ export class Manifest {
357
353
  this._data = data;
358
354
  let installedExtensionsChanged = false;
359
355
  if (
360
- await env.hasAppiumDependency(this.appiumHome) &&
356
+ (await env.hasAppiumDependency(this.appiumHome)) &&
361
357
  (await packageDidChange(this.appiumHome))
362
358
  ) {
363
359
  installedExtensionsChanged = await this.syncWithInstalledExtensions();
@@ -382,14 +378,14 @@ export class Manifest {
382
378
  * @private
383
379
  * @returns {Promise<string>}
384
380
  */
385
- async _setManifestPath () {
381
+ async _setManifestPath() {
386
382
  if (!this._manifestPath) {
387
383
  this._manifestPath = await env.resolveManifestPath(this._appiumHome);
388
384
 
389
385
  /* istanbul ignore if */
390
386
  if (path.relative(this._appiumHome, this._manifestPath).startsWith('.')) {
391
387
  throw new Error(
392
- `Mismatch between location of APPIUM_HOME and manifest file. APPIUM_HOME: ${this.appiumHome}, manifest file: ${this._manifestPath}`,
388
+ `Mismatch between location of APPIUM_HOME and manifest file. APPIUM_HOME: ${this.appiumHome}, manifest file: ${this._manifestPath}`
393
389
  );
394
390
  }
395
391
  }
@@ -405,7 +401,7 @@ export class Manifest {
405
401
  * @todo If this becomes too much of a bottleneck, throttle it.
406
402
  * @returns {Promise<boolean>} Whether the data was written
407
403
  */
408
- async write () {
404
+ async write() {
409
405
  if (this._writing) {
410
406
  return this._writing;
411
407
  }
@@ -416,21 +412,17 @@ export class Manifest {
416
412
  } catch (err) {
417
413
  throw new Error(
418
414
  `Appium could not create the directory for the manifest file: ${path.dirname(
419
- this._manifestPath,
420
- )}. Original error: ${err.message}`,
415
+ this._manifestPath
416
+ )}. Original error: ${err.message}`
421
417
  );
422
418
  }
423
419
  try {
424
- await fs.writeFile(
425
- this._manifestPath,
426
- YAML.stringify(this._data),
427
- 'utf8',
428
- );
420
+ await fs.writeFile(this._manifestPath, YAML.stringify(this._data), 'utf8');
429
421
  return true;
430
422
  } catch (err) {
431
423
  throw new Error(
432
424
  `Appium could not write to manifest at ${this._manifestPath} using APPIUM_HOME ${this._appiumHome}. ` +
433
- `Please ensure it is writable. Original error: ${err.message}`,
425
+ `Please ensure it is writable. Original error: ${err.message}`
434
426
  );
435
427
  }
436
428
  })();
@@ -444,12 +436,12 @@ export class Manifest {
444
436
 
445
437
  /**
446
438
  * Type of the string referring to a driver (typically as a key or type string)
447
- * @typedef {import('../../types').DriverType} DriverType
439
+ * @typedef {import('@appium/types').DriverType} DriverType
448
440
  */
449
441
 
450
442
  /**
451
443
  * Type of the string referring to a plugin (typically as a key or type string)
452
- * @typedef {import('../../types').PluginType} PluginType
444
+ * @typedef {import('@appium/types').PluginType} PluginType
453
445
  */
454
446
 
455
447
  /**
@@ -458,27 +450,26 @@ export class Manifest {
458
450
  */
459
451
 
460
452
  /**
461
- * @typedef {import('../../types/appium-manifest').ManifestData} ManifestData
462
- * @typedef {import('../../types/appium-manifest').InternalMetadata} InternalMetadata
453
+ * @typedef {import('appium/types').ManifestData} ManifestData
454
+ * @typedef {import('appium/types').InternalMetadata} InternalMetadata
463
455
  */
464
456
 
465
457
  /**
466
458
  * @template T
467
- * @typedef {import('../../types/external-manifest').ExtPackageJson<T>} ExtPackageJson
459
+ * @typedef {import('appium/types').ExtPackageJson<T>} ExtPackageJson
468
460
  */
469
461
 
470
462
  /**
471
463
  * @template T
472
- * @typedef {import('../../types/appium-manifest').ExtManifest<T>} ExtManifest
464
+ * @typedef {import('appium/types').ExtManifest<T>} ExtManifest
473
465
  */
474
466
 
475
467
  /**
476
468
  * @template T
477
- * @typedef {import('../../types/appium-manifest').ExtRecord<T>} ExtRecord
469
+ * @typedef {import('appium/types').ExtRecord<T>} ExtRecord
478
470
  */
479
471
 
480
472
  /**
481
473
  * Either `driver` or `plugin` rn
482
- * @typedef {import('../../types').ExtensionType} ExtensionType
474
+ * @typedef {import('@appium/types').ExtensionType} ExtensionType
483
475
  */
484
-
@@ -1,8 +1,7 @@
1
-
2
- import { fs } from '@appium/support';
3
- import { isPackageChanged } from 'package-changed';
1
+ import {fs} from '@appium/support';
2
+ import {isPackageChanged} from 'package-changed';
4
3
  import path from 'path';
5
- import { PKG_HASHFILE_RELATIVE_PATH } from '../constants';
4
+ import {PKG_HASHFILE_RELATIVE_PATH} from '../constants';
6
5
  import log from '../logger';
7
6
 
8
7
  /**
@@ -14,7 +13,7 @@ import log from '../logger';
14
13
  * @param {string} appiumHome
15
14
  * @returns {Promise<boolean>} `true` if `package.json` `appiumHome` changed
16
15
  */
17
- export async function packageDidChange (appiumHome) {
16
+ export async function packageDidChange(appiumHome) {
18
17
  const hashFilename = path.join(appiumHome, PKG_HASHFILE_RELATIVE_PATH);
19
18
 
20
19
  // XXX: the types in `package-changed` seem to be wrong.
@@ -35,7 +34,7 @@ export async function packageDidChange (appiumHome) {
35
34
  await fs.mkdirp(hashFilenameDir);
36
35
  } catch (err) {
37
36
  throw new Error(
38
- `Appium could not create the directory for hash file: ${hashFilenameDir}. Original error: ${err.message}`,
37
+ `Appium could not create the directory for hash file: ${hashFilenameDir}. Original error: ${err.message}`
39
38
  );
40
39
  }
41
40
 
@@ -51,10 +50,12 @@ export async function packageDidChange (appiumHome) {
51
50
  if (isChanged) {
52
51
  try {
53
52
  writeHash();
54
- log.debug(`Updated hash of ${appiumHome}/package.json from: ${oldHash ?? '(none)'} to: ${hash}`);
53
+ log.debug(
54
+ `Updated hash of ${appiumHome}/package.json from: ${oldHash ?? '(none)'} to: ${hash}`
55
+ );
55
56
  } catch (err) {
56
57
  throw new Error(
57
- `Appium could not write hash file: ${hashFilenameDir}. Original error: ${err.message}`,
58
+ `Appium could not write hash file: ${hashFilenameDir}. Original error: ${err.message}`
58
59
  );
59
60
  }
60
61
  }