appium 2.0.0-beta.35 → 2.0.0-beta.39
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/build/lib/appium.d.ts +41 -52
- package/build/lib/appium.d.ts.map +1 -1
- package/build/lib/appium.js +32 -15
- package/build/lib/cli/args.d.ts +1 -1
- package/build/lib/cli/args.d.ts.map +1 -1
- package/build/lib/cli/args.js +1 -1
- package/build/lib/cli/driver-command.d.ts +3 -3
- package/build/lib/cli/driver-command.d.ts.map +1 -1
- package/build/lib/cli/driver-command.js +1 -1
- package/build/lib/cli/extension-command.d.ts +60 -38
- package/build/lib/cli/extension-command.d.ts.map +1 -1
- package/build/lib/cli/extension-command.js +115 -59
- package/build/lib/cli/extension.d.ts +9 -5
- package/build/lib/cli/extension.d.ts.map +1 -1
- package/build/lib/cli/extension.js +5 -7
- package/build/lib/cli/parser.d.ts +3 -3
- package/build/lib/cli/parser.d.ts.map +1 -1
- package/build/lib/cli/parser.js +1 -1
- package/build/lib/cli/plugin-command.d.ts +1 -1
- package/build/lib/cli/plugin-command.d.ts.map +1 -1
- package/build/lib/cli/plugin-command.js +1 -1
- package/build/lib/cli/utils.js +1 -1
- package/build/lib/config-file.d.ts.map +1 -1
- package/build/lib/config-file.js +1 -1
- package/build/lib/config.d.ts +4 -4
- package/build/lib/config.d.ts.map +1 -1
- package/build/lib/config.js +1 -1
- package/build/lib/constants.d.ts.map +1 -1
- package/build/lib/constants.js +1 -1
- package/build/lib/extension/driver-config.d.ts +29 -32
- package/build/lib/extension/driver-config.d.ts.map +1 -1
- package/build/lib/extension/driver-config.js +7 -20
- package/build/lib/extension/extension-config.d.ts +108 -36
- package/build/lib/extension/extension-config.d.ts.map +1 -1
- package/build/lib/extension/extension-config.js +199 -60
- package/build/lib/extension/index.d.ts +16 -7
- package/build/lib/extension/index.d.ts.map +1 -1
- package/build/lib/extension/index.js +15 -18
- package/build/lib/extension/manifest.d.ts +12 -12
- package/build/lib/extension/manifest.d.ts.map +1 -1
- package/build/lib/extension/manifest.js +13 -3
- package/build/lib/extension/package-changed.d.ts.map +1 -1
- package/build/lib/extension/package-changed.js +1 -1
- package/build/lib/extension/plugin-config.d.ts +19 -24
- package/build/lib/extension/plugin-config.d.ts.map +1 -1
- package/build/lib/extension/plugin-config.js +9 -18
- package/build/lib/grid-register.d.ts.map +1 -1
- package/build/lib/grid-register.js +1 -1
- package/build/lib/logger.d.ts +1 -1
- package/build/lib/logger.d.ts.map +1 -1
- package/build/lib/logger.js +1 -1
- package/build/lib/logsink.d.ts.map +1 -1
- package/build/lib/logsink.js +3 -2
- package/build/lib/main.d.ts +13 -12
- package/build/lib/main.d.ts.map +1 -1
- package/build/lib/main.js +4 -4
- package/build/lib/schema/arg-spec.d.ts +4 -4
- package/build/lib/schema/arg-spec.d.ts.map +1 -1
- package/build/lib/schema/arg-spec.js +1 -1
- package/build/lib/schema/cli-args.d.ts.map +1 -1
- package/build/lib/schema/cli-args.js +1 -1
- package/build/lib/schema/cli-transformers.d.ts.map +1 -1
- package/build/lib/schema/cli-transformers.js +1 -1
- package/build/lib/schema/keywords.d.ts.map +1 -1
- package/build/lib/schema/keywords.js +1 -1
- package/build/lib/schema/schema.d.ts +2 -2
- package/build/lib/schema/schema.d.ts.map +1 -1
- package/build/lib/schema/schema.js +1 -1
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types/appium-manifest.d.ts +23 -4
- package/build/types/appium-manifest.d.ts.map +1 -1
- package/build/types/cli.d.ts.map +1 -1
- package/build/types/{external-manifest.d.ts → extension-manifest.d.ts} +15 -7
- package/build/types/extension-manifest.d.ts.map +1 -0
- package/build/types/index.d.ts +6 -5
- package/build/types/index.d.ts.map +1 -1
- package/driver.d.ts +1 -0
- package/driver.js +14 -0
- package/lib/appium.js +208 -124
- package/lib/cli/args.js +143 -93
- package/lib/cli/driver-command.js +10 -15
- package/lib/cli/extension-command.js +226 -175
- package/lib/cli/extension.js +15 -19
- package/lib/cli/parser.js +19 -31
- package/lib/cli/plugin-command.js +8 -8
- package/lib/cli/utils.js +8 -14
- package/lib/config-file.js +21 -25
- package/lib/config.js +82 -64
- package/lib/constants.js +4 -13
- package/lib/extension/driver-config.js +171 -171
- package/lib/extension/extension-config.js +347 -126
- package/lib/extension/index.js +72 -58
- package/lib/extension/manifest.js +48 -57
- package/lib/extension/package-changed.js +9 -8
- package/lib/extension/plugin-config.js +62 -62
- package/lib/grid-register.js +29 -18
- package/lib/logger.js +1 -2
- package/lib/logsink.js +29 -31
- package/lib/main.js +111 -73
- package/lib/schema/arg-spec.js +10 -13
- package/lib/schema/cli-args.js +14 -37
- package/lib/schema/cli-transformers.js +7 -14
- package/lib/schema/keywords.js +15 -13
- package/lib/schema/schema.js +58 -75
- package/lib/utils.js +50 -25
- package/package.json +25 -18
- package/plugin.d.ts +1 -0
- package/plugin.js +13 -0
- package/scripts/autoinstall-extensions.js +177 -0
- package/support.d.ts +1 -0
- package/support.js +13 -0
- package/types/appium-manifest.ts +27 -15
- package/types/cli.ts +2 -9
- package/types/{external-manifest.ts → extension-manifest.ts} +21 -15
- package/types/index.ts +12 -5
- package/build/types/extension.d.ts +0 -43
- package/build/types/extension.d.ts.map +0 -1
- package/build/types/external-manifest.d.ts.map +0 -1
- package/scripts/postinstall.js +0 -71
- package/types/extension.ts +0 -56
package/lib/extension/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
1
|
import _ from 'lodash';
|
|
3
|
-
import {
|
|
2
|
+
import {USE_ALL_PLUGINS} from '../constants';
|
|
4
3
|
import log from '../logger';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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
|
|
20
|
+
export async function loadExtensions(appiumHome) {
|
|
21
21
|
const manifest = Manifest.getInstance(appiumHome);
|
|
22
|
-
|
|
23
|
-
const driverConfig =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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 {
|
|
38
|
+
* @returns {PluginNameMap} Mapping of PluginClass to name
|
|
41
39
|
*/
|
|
42
|
-
export function getActivePlugins
|
|
43
|
-
return
|
|
44
|
-
|
|
45
|
-
.
|
|
46
|
-
(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
.
|
|
80
|
-
(driverName) =>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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 {
|
|
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 {
|
|
9
|
+
import {DRIVER_TYPE, PLUGIN_TYPE} from '../constants';
|
|
10
10
|
import log from '../logger';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 ${
|
|
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 {
|
|
276
|
+
* @returns {ExtManifest<ExtType>} A clone of `extData`, potentially with a mutated `appiumVersion` field
|
|
284
277
|
*/
|
|
285
|
-
addExtension
|
|
286
|
-
|
|
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
|
|
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('
|
|
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('
|
|
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('
|
|
462
|
-
* @typedef {import('
|
|
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('
|
|
459
|
+
* @typedef {import('appium/types').ExtPackageJson<T>} ExtPackageJson
|
|
468
460
|
*/
|
|
469
461
|
|
|
470
462
|
/**
|
|
471
463
|
* @template T
|
|
472
|
-
* @typedef {import('
|
|
464
|
+
* @typedef {import('appium/types').ExtManifest<T>} ExtManifest
|
|
473
465
|
*/
|
|
474
466
|
|
|
475
467
|
/**
|
|
476
468
|
* @template T
|
|
477
|
-
* @typedef {import('
|
|
469
|
+
* @typedef {import('appium/types').ExtRecord<T>} ExtRecord
|
|
478
470
|
*/
|
|
479
471
|
|
|
480
472
|
/**
|
|
481
473
|
* Either `driver` or `plugin` rn
|
|
482
|
-
* @typedef {import('
|
|
474
|
+
* @typedef {import('@appium/types').ExtensionType} ExtensionType
|
|
483
475
|
*/
|
|
484
|
-
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
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 {
|
|
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
|
|
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(
|
|
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
|
}
|