appium 2.0.0-beta.5 → 2.0.0-beta.52
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/README.md +156 -63
- package/build/lib/appium.d.ts +226 -0
- package/build/lib/appium.d.ts.map +1 -0
- package/build/lib/appium.js +694 -439
- package/build/lib/appium.js.map +1 -0
- package/build/lib/cli/args.d.ts +17 -0
- package/build/lib/cli/args.d.ts.map +1 -0
- package/build/lib/cli/args.js +253 -319
- package/build/lib/cli/args.js.map +1 -0
- package/build/lib/cli/driver-command.d.ts +102 -0
- package/build/lib/cli/driver-command.d.ts.map +1 -0
- package/build/lib/cli/driver-command.js +126 -81
- package/build/lib/cli/driver-command.js.map +1 -0
- package/build/lib/cli/extension-command.d.ts +385 -0
- package/build/lib/cli/extension-command.d.ts.map +1 -0
- package/build/lib/cli/extension-command.js +731 -383
- package/build/lib/cli/extension-command.js.map +1 -0
- package/build/lib/cli/extension.d.ts +23 -0
- package/build/lib/cli/extension.d.ts.map +1 -0
- package/build/lib/cli/extension.js +71 -54
- package/build/lib/cli/extension.js.map +1 -0
- package/build/lib/cli/parser.d.ts +84 -0
- package/build/lib/cli/parser.d.ts.map +1 -0
- package/build/lib/cli/parser.js +240 -128
- package/build/lib/cli/parser.js.map +1 -0
- package/build/lib/cli/plugin-command.d.ts +99 -0
- package/build/lib/cli/plugin-command.d.ts.map +1 -0
- package/build/lib/cli/plugin-command.js +120 -81
- package/build/lib/cli/plugin-command.js.map +1 -0
- package/build/lib/cli/utils.d.ts +29 -0
- package/build/lib/cli/utils.d.ts.map +1 -0
- package/build/lib/cli/utils.js +72 -51
- package/build/lib/cli/utils.js.map +1 -0
- package/build/lib/config-file.d.ts +100 -0
- package/build/lib/config-file.d.ts.map +1 -0
- package/build/lib/config-file.js +207 -0
- package/build/lib/config-file.js.map +1 -0
- package/build/lib/config.d.ts +49 -0
- package/build/lib/config.d.ts.map +1 -0
- package/build/lib/config.js +265 -201
- package/build/lib/config.js.map +1 -0
- package/build/lib/constants.d.ts +49 -0
- package/build/lib/constants.d.ts.map +1 -0
- package/build/lib/constants.js +66 -0
- package/build/lib/constants.js.map +1 -0
- package/build/lib/extension/driver-config.d.ts +82 -0
- package/build/lib/extension/driver-config.d.ts.map +1 -0
- package/build/lib/extension/driver-config.js +212 -0
- package/build/lib/extension/driver-config.js.map +1 -0
- package/build/lib/extension/extension-config.d.ts +249 -0
- package/build/lib/extension/extension-config.d.ts.map +1 -0
- package/build/lib/extension/extension-config.js +581 -0
- package/build/lib/extension/extension-config.js.map +1 -0
- package/build/lib/extension/index.d.ts +48 -0
- package/build/lib/extension/index.d.ts.map +1 -0
- package/build/lib/extension/index.js +105 -0
- package/build/lib/extension/index.js.map +1 -0
- package/build/lib/extension/manifest-migrations.d.ts +27 -0
- package/build/lib/extension/manifest-migrations.d.ts.map +1 -0
- package/build/lib/extension/manifest-migrations.js +118 -0
- package/build/lib/extension/manifest-migrations.js.map +1 -0
- package/build/lib/extension/manifest.d.ts +145 -0
- package/build/lib/extension/manifest.d.ts.map +1 -0
- package/build/lib/extension/manifest.js +521 -0
- package/build/lib/extension/manifest.js.map +1 -0
- package/build/lib/extension/package-changed.d.ts +11 -0
- package/build/lib/extension/package-changed.d.ts.map +1 -0
- package/build/lib/extension/package-changed.js +62 -0
- package/build/lib/extension/package-changed.js.map +1 -0
- package/build/lib/extension/plugin-config.d.ts +56 -0
- package/build/lib/extension/plugin-config.d.ts.map +1 -0
- package/build/lib/extension/plugin-config.js +102 -0
- package/build/lib/extension/plugin-config.js.map +1 -0
- package/build/lib/grid-register.d.ts +10 -0
- package/build/lib/grid-register.d.ts.map +1 -0
- package/build/lib/grid-register.js +122 -144
- package/build/lib/grid-register.js.map +1 -0
- package/build/lib/logger.d.ts +3 -0
- package/build/lib/logger.d.ts.map +1 -0
- package/build/lib/logger.js +5 -17
- package/build/lib/logger.js.map +1 -0
- package/build/lib/logsink.d.ts +4 -0
- package/build/lib/logsink.d.ts.map +1 -0
- package/build/lib/logsink.js +190 -187
- package/build/lib/logsink.js.map +1 -0
- package/build/lib/main.d.ts +62 -0
- package/build/lib/main.d.ts.map +1 -0
- package/build/lib/main.js +348 -228
- package/build/lib/main.js.map +1 -0
- package/build/lib/schema/arg-spec.d.ts +143 -0
- package/build/lib/schema/arg-spec.d.ts.map +1 -0
- package/build/lib/schema/arg-spec.js +164 -0
- package/build/lib/schema/arg-spec.js.map +1 -0
- package/build/lib/schema/cli-args.d.ts +19 -0
- package/build/lib/schema/cli-args.d.ts.map +1 -0
- package/build/lib/schema/cli-args.js +217 -0
- package/build/lib/schema/cli-args.js.map +1 -0
- package/build/lib/schema/cli-transformers.d.ts +5 -0
- package/build/lib/schema/cli-transformers.d.ts.map +1 -0
- package/build/lib/schema/cli-transformers.js +124 -0
- package/build/lib/schema/cli-transformers.js.map +1 -0
- package/build/lib/schema/index.d.ts +3 -0
- package/build/lib/schema/index.d.ts.map +1 -0
- package/build/lib/schema/index.js +19 -0
- package/build/lib/schema/index.js.map +1 -0
- package/build/lib/schema/keywords.d.ts +24 -0
- package/build/lib/schema/keywords.d.ts.map +1 -0
- package/build/lib/schema/keywords.js +128 -0
- package/build/lib/schema/keywords.js.map +1 -0
- package/build/lib/schema/schema.d.ts +259 -0
- package/build/lib/schema/schema.d.ts.map +1 -0
- package/build/lib/schema/schema.js +615 -0
- package/build/lib/schema/schema.js.map +1 -0
- package/build/lib/utils.d.ts +121 -0
- package/build/lib/utils.d.ts.map +1 -0
- package/build/lib/utils.js +351 -273
- package/build/lib/utils.js.map +1 -0
- package/build/tsconfig.tsbuildinfo +1 -0
- package/build/types/cli.d.ts +134 -0
- package/build/types/cli.d.ts.map +1 -0
- package/build/types/cli.js +3 -0
- package/build/types/cli.js.map +1 -0
- package/build/types/index.d.ts +15 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/index.js +19 -0
- package/build/types/index.js.map +1 -0
- package/build/types/manifest/base.d.ts +135 -0
- package/build/types/manifest/base.d.ts.map +1 -0
- package/build/types/manifest/base.js +3 -0
- package/build/types/manifest/base.js.map +1 -0
- package/build/types/manifest/index.d.ts +19 -0
- package/build/types/manifest/index.d.ts.map +1 -0
- package/build/types/manifest/index.js +40 -0
- package/build/types/manifest/index.js.map +1 -0
- package/build/types/manifest/v3.d.ts +139 -0
- package/build/types/manifest/v3.d.ts.map +1 -0
- package/build/types/manifest/v3.js +3 -0
- package/build/types/manifest/v3.js.map +1 -0
- package/driver.d.ts +1 -0
- package/driver.js +14 -0
- package/index.js +11 -0
- package/lib/appium.js +535 -186
- package/lib/cli/args.js +267 -422
- package/lib/cli/driver-command.js +126 -23
- package/lib/cli/extension-command.js +679 -271
- package/lib/cli/extension.js +48 -17
- package/lib/cli/parser.js +263 -83
- package/lib/cli/plugin-command.js +115 -20
- package/lib/cli/utils.js +24 -10
- package/lib/config-file.js +220 -0
- package/lib/config.js +244 -110
- package/lib/constants.js +71 -0
- package/lib/extension/driver-config.js +250 -0
- package/lib/extension/extension-config.js +682 -0
- package/lib/extension/index.js +116 -0
- package/lib/extension/manifest-migrations.js +120 -0
- package/lib/extension/manifest.js +573 -0
- package/lib/extension/package-changed.js +64 -0
- package/lib/extension/plugin-config.js +112 -0
- package/lib/grid-register.js +49 -35
- package/lib/logger.js +1 -2
- package/lib/logsink.js +64 -38
- package/lib/main.js +321 -101
- package/lib/schema/arg-spec.js +229 -0
- package/lib/schema/cli-args.js +238 -0
- package/lib/schema/cli-transformers.js +119 -0
- package/lib/schema/index.js +2 -0
- package/lib/schema/keywords.js +136 -0
- package/lib/schema/schema.js +722 -0
- package/lib/utils.js +291 -167
- package/package.json +83 -84
- package/plugin.d.ts +1 -0
- package/plugin.js +13 -0
- package/scripts/autoinstall-extensions.js +237 -0
- package/support.d.ts +1 -0
- package/support.js +13 -0
- package/tsconfig.json +25 -0
- package/types/cli.ts +189 -0
- package/types/index.ts +20 -0
- package/types/manifest/README.md +30 -0
- package/types/manifest/base.ts +158 -0
- package/types/manifest/index.ts +27 -0
- package/types/manifest/v3.ts +161 -0
- package/CHANGELOG.md +0 -3515
- package/bin/ios-webkit-debug-proxy-launcher.js +0 -71
- package/build/lib/cli/npm.js +0 -208
- package/build/lib/cli/parser-helpers.js +0 -82
- package/build/lib/driver-config.js +0 -77
- package/build/lib/drivers.js +0 -96
- package/build/lib/extension-config.js +0 -253
- package/build/lib/plugin-config.js +0 -59
- package/build/lib/plugins.js +0 -14
- package/lib/cli/npm.js +0 -184
- package/lib/cli/parser-helpers.js +0 -79
- package/lib/driver-config.js +0 -46
- package/lib/drivers.js +0 -81
- package/lib/extension-config.js +0 -209
- package/lib/plugin-config.js +0 -34
- package/lib/plugins.js +0 -10
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import {USE_ALL_PLUGINS} from '../constants';
|
|
3
|
+
import log from '../logger';
|
|
4
|
+
import {DriverConfig} from './driver-config';
|
|
5
|
+
import {Manifest} from './manifest';
|
|
6
|
+
import {PluginConfig} from './plugin-config';
|
|
7
|
+
import B from 'bluebird';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Loads extensions and creates `ExtensionConfig` instances.
|
|
11
|
+
*
|
|
12
|
+
* - Reads the manifest file, creating if necessary
|
|
13
|
+
* - Using the parsed extension data, creates/gets the `ExtensionConfig` subclass instances
|
|
14
|
+
* - Returns these instances
|
|
15
|
+
*
|
|
16
|
+
* If `appiumHome` is needed, use `resolveAppiumHome` from the `env` module in `@appium/support`.
|
|
17
|
+
* @param {string} appiumHome
|
|
18
|
+
* @returns {Promise<ExtensionConfigs>}
|
|
19
|
+
*/
|
|
20
|
+
export async function loadExtensions(appiumHome) {
|
|
21
|
+
const manifest = Manifest.getInstance(appiumHome);
|
|
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()]);
|
|
27
|
+
return {driverConfig, pluginConfig};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Find any plugin name which has been installed, and which has been requested for activation by
|
|
32
|
+
* using the --use-plugins flag, and turn each one into its class, so we can send them as objects
|
|
33
|
+
* to the server init. We also want to send/assign them to the umbrella driver so it can use them
|
|
34
|
+
* to wrap command execution
|
|
35
|
+
*
|
|
36
|
+
* @param {import('./plugin-config').PluginConfig} pluginConfig - a plugin extension config
|
|
37
|
+
* @param {string[]} usePlugins
|
|
38
|
+
* @returns {PluginNameMap} Mapping of PluginClass to name
|
|
39
|
+
*/
|
|
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
|
+
)
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Find any driver name which has been installed, and turn each one into its class, so we can send
|
|
68
|
+
* them as objects to the server init in case they need to add methods/routes or update the server.
|
|
69
|
+
* If the --drivers flag was given, this method only loads the given drivers.
|
|
70
|
+
*
|
|
71
|
+
* @param {import('./driver-config').DriverConfig} driverConfig - a driver extension config
|
|
72
|
+
* @param {string[]} [useDrivers] - optional list of drivers to load
|
|
73
|
+
* @returns {DriverNameMap}
|
|
74
|
+
*/
|
|
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
|
+
)
|
|
94
|
+
);
|
|
95
|
+
}
|
|
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
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @typedef ExtensionConfigs
|
|
114
|
+
* @property {import('./driver-config').DriverConfig} driverConfig
|
|
115
|
+
* @property {import('./plugin-config').PluginConfig} pluginConfig
|
|
116
|
+
*/
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import {DRIVER_TYPE, PLUGIN_TYPE} from '../constants';
|
|
2
|
+
import log from '../logger';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This contains logic to migrate old versions of `extensions.yaml` to new versions.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Constant for v3 of the schema rev.
|
|
12
|
+
*/
|
|
13
|
+
const SCHEMA_REV_3 = 3;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Collection of functions to migrate from one version to another.
|
|
17
|
+
*
|
|
18
|
+
* These functions _should not actually perform the migration_; rather, they
|
|
19
|
+
* should return `true` if the migration should be performed. The migration
|
|
20
|
+
* itself will happen within {@linkcode Manifest.syncWithInstalledExtensions}; the extensions
|
|
21
|
+
* will be checked and the manifest file updated per the state of the filesystem.
|
|
22
|
+
*
|
|
23
|
+
* @type {{[P in keyof ManifestDataVersions]?: Migration}}
|
|
24
|
+
*/
|
|
25
|
+
const Migrations = {
|
|
26
|
+
/**
|
|
27
|
+
* If `installPath` is missing from the `ExtManifest` for any extension, return `true`.
|
|
28
|
+
*
|
|
29
|
+
* We cannot easily determine the path of any given extension here, but returning `true`
|
|
30
|
+
* will cause the `Manifest` to sync with the filesystem, which will populate the missing field.
|
|
31
|
+
*
|
|
32
|
+
* @type {Migration}
|
|
33
|
+
*/
|
|
34
|
+
[SCHEMA_REV_3]: (manifest) => {
|
|
35
|
+
let shouldSync = false;
|
|
36
|
+
/** @type {Array<ExtManifest<PluginType>|ExtManifest<DriverType>>} */
|
|
37
|
+
const allExtData = [
|
|
38
|
+
...Object.values(manifest.getExtensionData(DRIVER_TYPE)),
|
|
39
|
+
...Object.values(manifest.getExtensionData(PLUGIN_TYPE)),
|
|
40
|
+
];
|
|
41
|
+
for (const metadata of allExtData) {
|
|
42
|
+
if (!('installPath' in metadata)) {
|
|
43
|
+
shouldSync = true;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return shouldSync;
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Set `schemaRev` to a specific version.
|
|
53
|
+
*
|
|
54
|
+
* This _does_ mutate `data` in-place, unlike functions in
|
|
55
|
+
* {@linkcode Migrations}.
|
|
56
|
+
*
|
|
57
|
+
* Again, returning `true` means that the manifest should be--at
|
|
58
|
+
* minimum--persisted to disk, since we changed it.
|
|
59
|
+
* @param {Readonly<Manifest>} manifest
|
|
60
|
+
* @param {keyof ManifestDataVersions} version
|
|
61
|
+
* @returns {boolean} Whether the data was modified
|
|
62
|
+
*/
|
|
63
|
+
function setSchemaRev(manifest, version) {
|
|
64
|
+
if (manifest.schemaRev ?? 0 < version) {
|
|
65
|
+
manifest.setSchemaRev(version);
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Applies a series of migration functions to a manifest to update its manifest schema version.
|
|
73
|
+
*
|
|
74
|
+
* `data` is modified in-place.
|
|
75
|
+
*
|
|
76
|
+
* @param {Readonly<Manifest>} manifest
|
|
77
|
+
* @returns {Promise<boolean>} If `true` existing packages should be synced from disk and the manifest should be persisted.
|
|
78
|
+
*/
|
|
79
|
+
export async function migrate(manifest) {
|
|
80
|
+
let didChange = false;
|
|
81
|
+
for await (const [v, migration] of Object.entries(Migrations)) {
|
|
82
|
+
const version = /** @type {keyof ManifestDataVersions} */ (Number(v));
|
|
83
|
+
didChange = (await migration(manifest)) || didChange;
|
|
84
|
+
didChange = setSchemaRev(manifest, version) || didChange;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (didChange) {
|
|
88
|
+
// this is not _technically_ true, since we don't actually write the file here.
|
|
89
|
+
log.info(`Upgraded extension manifest to schema v${manifest.schemaRev}`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return didChange;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* A migration function. It will return `true` if a change _should be made_.
|
|
97
|
+
*
|
|
98
|
+
* A migration function should not modify `schemaRev`, as this is done automatically.
|
|
99
|
+
*
|
|
100
|
+
* Note that at the time of writing, we're not able to determine the version of the _current_ manifest file if there is no `schemaRev` prop present (and we may not want to trust it anyway).
|
|
101
|
+
* @callback Migration
|
|
102
|
+
* @param {Readonly<Manifest>} manifest - The `Manifest` instance
|
|
103
|
+
* @returns {boolean|Promise<boolean>} If `true`, then something changed
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @typedef {import('appium/types').ManifestData} ManifestData
|
|
108
|
+
* @typedef {import('@appium/types').DriverType} DriverType
|
|
109
|
+
* @typedef {import('@appium/types').PluginType} PluginType
|
|
110
|
+
* @typedef {import('appium/types').AnyManifestDataVersion} AnyManifestDataVersion
|
|
111
|
+
* @typedef {import('appium/types').ManifestDataVersions} ManifestDataVersions
|
|
112
|
+
* @typedef {import('@appium/types').ExtensionType} ExtensionType
|
|
113
|
+
* @typedef {import('appium/types').ManifestV2.ManifestData} ManifestDataV2
|
|
114
|
+
* @typedef {import('./manifest').Manifest} Manifest
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @template {ExtensionType} ExtType
|
|
119
|
+
* @typedef {import('appium/types').ExtManifest<ExtType>} ExtManifest
|
|
120
|
+
*/
|