Add exec Node API to FlipperLib

Summary: Changelog: Allow flipper plugins to run "exec" Node API on Flipper server.

Reviewed By: mweststrate

Differential Revision: D32881149

fbshipit-source-id: 46486a47ee9824ca68897c19fd86b4afc7f8bf1d
This commit is contained in:
Andrey Goncharov
2021-12-10 06:34:37 -08:00
committed by Facebook GitHub Bot
parent 8ca2c59499
commit e458ae76f9
10 changed files with 121 additions and 3 deletions

View File

@@ -132,6 +132,13 @@ export type IOSDeviceParams = {
};
export type FlipperServerCommands = {
/**
* @throws ExecError
*/
'node-api-exec': (
command: string,
options?: ExecOptions & {encoding?: BufferEncoding},
) => Promise<ExecOut<string>>;
'get-config': () => Promise<FlipperServerConfig>;
'get-changelog': () => Promise<string>;
'device-list': () => Promise<DeviceDescription[]>;
@@ -270,6 +277,38 @@ type ENVIRONMENT_PATHS =
| 'tempPath'
| 'desktopPath';
export interface ExecOptions {
maxBuffer?: number;
timeout?: number;
}
export interface ExecError {
message: string;
stdout: string;
stderr: string;
stack?: string;
cmd?: string;
killed?: boolean;
code?: number;
}
export interface ExecOut<StdOutErrType> {
stdout: StdOutErrType;
stderr: StdOutErrType;
}
export type BufferEncoding =
| 'ascii'
| 'utf8'
| 'utf-8'
| 'utf16le'
| 'ucs2'
| 'ucs-2'
| 'base64'
| 'base64url'
| 'latin1'
| 'binary'
| 'hex';
export type FlipperServerConfig = {
gatekeepers: Record<string, boolean>;
env: Partial<Record<ENVIRONMENT_VARIABLES, string>>;