Rename RemoteNodeAPI tp RemoteServerContext

Reviewed By: mweststrate

Differential Revision: D32921160

fbshipit-source-id: 9d6b723427d7a819f2fc1b7168f6d1077dc56bd9
This commit is contained in:
Andrey Goncharov
2021-12-10 06:34:37 -08:00
committed by Facebook GitHub Bot
parent 0e785fb18d
commit 4cb80a452f
8 changed files with 18 additions and 18 deletions

View File

@@ -112,7 +112,7 @@ test('Correct top level API exposed', () => {
"NormalizedMenuEntry", "NormalizedMenuEntry",
"Notification", "Notification",
"PluginClient", "PluginClient",
"RemoteNodeAPI", "RemoteServerContext",
] ]
`); `);
}); });

View File

@@ -39,7 +39,7 @@ export {
setFlipperLibImplementation as _setFlipperLibImplementation, setFlipperLibImplementation as _setFlipperLibImplementation,
FileDescriptor, FileDescriptor,
FileEncoding, FileEncoding,
RemoteNodeAPI, RemoteServerContext,
} from './plugin/FlipperLib'; } from './plugin/FlipperLib';
export { export {
MenuEntry, MenuEntry,

View File

@@ -28,7 +28,7 @@ export interface FileDescriptor {
path?: string; path?: string;
} }
export type RemoteNodeAPI = { export type RemoteServerContext = {
childProcess: { childProcess: {
exec( exec(
command: string, command: string,
@@ -134,7 +134,7 @@ export interface FlipperLib {
homePath: string; homePath: string;
appPath: string; appPath: string;
}; };
removeNodeAPI: RemoteNodeAPI; remoteServerContext: RemoteServerContext;
} }
export let flipperLibInstance: FlipperLib | undefined; export let flipperLibInstance: FlipperLib | undefined;

View File

@@ -389,7 +389,7 @@ export function createMockFlipperLib(options?: StartPluginOptions): FlipperLib {
appPath: process.cwd(), appPath: process.cwd(),
homePath: `/dev/null`, homePath: `/dev/null`,
}, },
removeNodeAPI: { remoteServerContext: {
childProcess: { childProcess: {
exec: jest.fn(), exec: jest.fn(),
}, },

View File

@@ -7,7 +7,10 @@
* @format * @format
*/ */
import {_setFlipperLibImplementation, RemoteNodeAPI} from 'flipper-plugin'; import {
_setFlipperLibImplementation,
RemoteServerContext,
} from 'flipper-plugin';
import type { import type {
BufferEncoding, BufferEncoding,
ExecOptions, ExecOptions,
@@ -68,17 +71,12 @@ export function initializeFlipperLibImplementation(
appPath: renderHost.serverConfig.paths.appPath, appPath: renderHost.serverConfig.paths.appPath,
homePath: renderHost.serverConfig.paths.homePath, homePath: renderHost.serverConfig.paths.homePath,
}, },
removeNodeAPI: { remoteServerContext: {
childProcess: { childProcess: {
exec: (async ( exec: async (
command: string, command: string,
options?: ExecOptions & {encoding?: BufferEncoding}, options?: ExecOptions & {encoding?: BufferEncoding},
) => ) => renderHost.flipperServer.exec('node-api-exec', command, options),
renderHost.flipperServer.exec(
'node-api-exec',
command,
options,
)) as RemoteNodeAPI['childProcess']['exec'],
}, },
fs: { fs: {
access: async (path: string, mode?: number) => access: async (path: string, mode?: number) =>
@@ -95,7 +93,7 @@ export function initializeFlipperLibImplementation(
'node-api-fs-mkdir', 'node-api-fs-mkdir',
path, path,
options, options,
)) as RemoteNodeAPI['fs']['mkdir'], )) as RemoteServerContext['fs']['mkdir'],
copyFile: async (src: string, dest: string, flags?: number) => copyFile: async (src: string, dest: string, flags?: number) =>
renderHost.flipperServer.exec( renderHost.flipperServer.exec(
'node-api-fs-copyFile', 'node-api-fs-copyFile',

View File

@@ -262,7 +262,7 @@ export default class AllocationsPlugin extends FlipperDevicePlugin<
} }
async init() { async init() {
await getFlipperLib().removeNodeAPI.childProcess.exec( await getFlipperLib().remoteServerContext.childProcess.exec(
'adb forward tcp:6000 localfilesystem:/data/local/debugger-socket', 'adb forward tcp:6000 localfilesystem:/data/local/debugger-socket',
); );
await this.connectToDebugApi(); await this.connectToDebugApi();

View File

@@ -81,7 +81,7 @@ export default class KaiOSGraphs extends FlipperDevicePlugin<State, any, any> {
async init() { async init() {
try { try {
await getFlipperLib().removeNodeAPI.childProcess.exec('adb root'); await getFlipperLib().remoteServerContext.childProcess.exec('adb root');
} catch (e) { } catch (e) {
console.error('Error obtaining root on the device', e); console.error('Error obtaining root on the device', e);
} }

View File

@@ -33,7 +33,9 @@ const DEV_TOOLS_PORT = 8097; // hardcoded in RN
async function findGlobalDevTools(): Promise<string | undefined> { async function findGlobalDevTools(): Promise<string | undefined> {
try { try {
const {stdout: basePath} = const {stdout: basePath} =
await getFlipperLib().removeNodeAPI.childProcess.exec('npm root -g'); await getFlipperLib().remoteServerContext.childProcess.exec(
'npm root -g',
);
const devToolsPath = path.join( const devToolsPath = path.join(
basePath.trim(), basePath.trim(),
'react-devtools', 'react-devtools',