mirror of
https://github.com/appium/appium.git
synced 2026-10-25 02:00:57 +08:00
This changes how plugins handle CLI args: - The `cliArgs` instance prop of a `Plugin` will never be `undefined`. If there are no args, the prop will be an empty object. - The `cliArgs` instance prop of a `Plugin` will now contain default values, if any were provided by the `Plugin`'s schema. This differs from how the same property is handled in drivers. To that end, I split `AppiumDriver#getCliArgsForExtension()` (previously `assignCliArgsToExtension()`) into two separate methods for clarity. This change also contains a few associated improvements to tests and types.
35 lines
880 B
JavaScript
35 lines
880 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,unknown>} [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
|
|
*/
|