Extend Flipper commands to support server add-on messaging
Reviewed By: mweststrate Differential Revision: D34046466 fbshipit-source-id: 9acc172c1805ec724b8709999bacf9e899c39e6b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
3b390b74ff
commit
12151e4a71
@@ -15,6 +15,7 @@ import {default as axios} from 'axios';
|
||||
import {
|
||||
BundledPluginDetails,
|
||||
DownloadablePluginDetails,
|
||||
ExecuteMessage,
|
||||
InstalledPluginDetails,
|
||||
} from 'flipper-common';
|
||||
import {getStaticPath} from '../utils/pathUtils';
|
||||
@@ -43,6 +44,9 @@ const getTempDirName = promisify(tmp.dir) as (
|
||||
options?: tmp.DirOptions,
|
||||
) => Promise<string>;
|
||||
|
||||
const isExecuteMessage = (message: object): message is ExecuteMessage =>
|
||||
(message as ExecuteMessage).method === 'execute';
|
||||
|
||||
export class PluginManager {
|
||||
private readonly serverAddOns = new Map<string, ServerAddOn>();
|
||||
|
||||
@@ -155,6 +159,17 @@ export class PluginManager {
|
||||
}
|
||||
}
|
||||
|
||||
getServerAddOnForMessage(message: object) {
|
||||
if (!isExecuteMessage(message)) {
|
||||
throw new Error(
|
||||
`PluginManager.getServerAddOnForMessage supports only "execute" messages. Received ${JSON.stringify(
|
||||
message,
|
||||
)}`,
|
||||
);
|
||||
}
|
||||
return this.serverAddOns.get(message.params.api);
|
||||
}
|
||||
|
||||
async startServerAddOn(pluginName: string, owner: string) {
|
||||
console.debug('PluginManager.startServerAddOn', pluginName);
|
||||
const existingServerAddOn = this.serverAddOns.get(pluginName);
|
||||
|
||||
Reference in New Issue
Block a user