mirror of
https://github.com/appium/appium.git
synced 2026-02-22 03:08:47 -06:00
This PR changes the shape of plugin classes as well as how CLI args get assigned. - The `pluginName` static property has been removed. `name` is now assigned via the `BasePlugin` constructor, and is derived from the plugin name in the manifest. This means that an implementor only needs to provide a `pluginName` in the manifest, and the data is not duplicated. The value in this map (the plugin name) is used to instantiate the plugin, instead of passing static `pluginName` property into the constructor. - CLI args are now passed in through the constructor instead of assigned to the plugin instance after the fact. Implementation details: `getActivePlugins()` and `getActiveDrivers()` now return a `Map` of an extension _class_ to an extension name. The key is _not_ an instance, and is effectively a singleton, so we are not at risk of a memory leak. This change does not otherwise affect drivers.
35 lines
871 B
JavaScript
35 lines
871 B
JavaScript
import {logger} from '@appium/support';
|
|
|
|
/**
|
|
* @implements {Plugin}
|
|
*/
|
|
class BasePlugin {
|
|
/**
|
|
* Subclasses should use type `import('@appium/types').MethodMap<SubclassName>`.
|
|
*
|
|
* This will verify that the commands in the `newMethodMap` property are
|
|
* valid. It is impossible to use a generic type param here; the type of this should really
|
|
* be something like `MethodMap<T extends BasePlugin>` but that isn't a thing TS does.
|
|
*
|
|
* @type {import('@appium/types').MethodMap<any>}
|
|
*/
|
|
static newMethodMap = {};
|
|
|
|
/**
|
|
* @param {string} name
|
|
* @param {Record<string,any>} [cliArgs]
|
|
*/
|
|
constructor(name, cliArgs) {
|
|
this.name = name;
|
|
this.cliArgs = cliArgs;
|
|
this.logger = logger.getLogger(`Plugin [${name}]`);
|
|
}
|
|
}
|
|
|
|
export default BasePlugin;
|
|
export {BasePlugin};
|
|
|
|
/**
|
|
* @typedef {import('@appium/types').Plugin} Plugin
|
|
*/
|