feat(fake-plugin): use peer deps

BREAKING CHANGE:

This now requires a peer dependency on `appium`
This commit is contained in:
Christopher Hiller
2022-05-04 18:02:51 -07:00
parent 189e85fc0b
commit eb460b915a
4 changed files with 21 additions and 22 deletions

View File

@@ -1,4 +1,4 @@
import {logger} from '@appium/support';
import {logger} from 'appium/support';
const log = logger.getLogger('FakePlugin');

View File

@@ -1,14 +1,18 @@
// @ts-check
/* eslint-disable no-case-declarations */
import BasePlugin from '@appium/base-plugin';
import {BasePlugin} from 'appium/plugin';
import B from 'bluebird';
export default class FakePlugin extends BasePlugin {
class FakePlugin extends BasePlugin {
async getFakePluginArgs() {
await B.delay(1);
return this.cliArgs;
}
/**
* @type {import('@appium/types').MethodMap<FakePlugin>}
*/
static newMethodMap = {
'/session/:sessionId/fake_data': {
GET: {command: 'getFakeSessionData', neverProxy: true},
@@ -23,6 +27,7 @@ export default class FakePlugin extends BasePlugin {
},
};
/** @type {string?} */
static _unexpectedData = null;
static fakeRoute(req, res) {
@@ -33,8 +38,9 @@ export default class FakePlugin extends BasePlugin {
res.send(JSON.stringify(FakePlugin._unexpectedData));
FakePlugin._unexpectedData = null;
}
// eslint-disable-next-line require-await
static async updateServer(expressApp /*, httpServer*/) {
// eslint-disable-next-line no-unused-vars,require-await
static async updateServer(expressApp, httpServer) {
expressApp.all('/fake', FakePlugin.fakeRoute);
expressApp.all('/unexpected', FakePlugin.unexpectedData);
}
@@ -68,9 +74,11 @@ export default class FakePlugin extends BasePlugin {
return `<<${handle}>>`;
}
onUnexpectedShutdown(driver, cause) {
// eslint-disable-next-line require-await
async onUnexpectedShutdown(driver, cause) {
FakePlugin._unexpectedData = `Session ended because ${cause}`;
}
}
export {FakePlugin};
export default FakePlugin;

View File

@@ -35,6 +35,9 @@
"bluebird": "3.7.2",
"lodash": "4.17.21"
},
"peerDependencies": {
"appium": "file:../appium"
},
"engines": {
"node": ">=12",
"npm": ">=6"

View File

@@ -1,19 +1,7 @@
{
"compilerOptions": {
"outDir": "./build",
"paths": {
"@appium/base-plugin": ["../base-plugin"],
"@appium/support": ["../support"]
}
"outDir": "build"
},
"extends": "../../config/tsconfig.base.json",
"include": ["lib"],
"references": [
{
"path": "../base-plugin"
},
{
"path": "../support"
}
]
}
"extends": "../../config/tsconfig.plugin.json",
"include": ["lib"]
}