Files
appium/packages/base-plugin/lib/plugin.js
T
Christopher Hiller e0f14b5931 chore(appium,base-plugin,types): cli args changes for plugins
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.
2022-05-20 14:08:52 -07:00

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
*/