Remove fs and os usage from Mobile Builds plugin
Summary: Changelog: Expose env info and FS rm command to flipper plugins. Reviewed By: mweststrate Differential Revision: D32988478 fbshipit-source-id: 3d0233f9eb34d3478b07e39b9401c0e30ca95135
This commit is contained in:
committed by
Facebook GitHub Bot
parent
adb2573a1f
commit
c96558a524
@@ -70,6 +70,7 @@ test('Correct top level API exposed', () => {
|
||||
"usePlugin",
|
||||
"useTrackedCallback",
|
||||
"useValue",
|
||||
"uuid",
|
||||
"withTrackingScope",
|
||||
]
|
||||
`);
|
||||
|
||||
@@ -133,6 +133,7 @@ export {createTablePlugin} from './utils/createTablePlugin';
|
||||
export {textContent} from './utils/textContent';
|
||||
import * as path from './utils/path';
|
||||
export {path};
|
||||
export * from './utils/uuid';
|
||||
|
||||
// It's not ideal that this exists in flipper-plugin sources directly,
|
||||
// but is the least pain for plugin authors.
|
||||
|
||||
@@ -21,6 +21,9 @@ import {
|
||||
DownloadFileStartOptions,
|
||||
DownloadFileStartResponse,
|
||||
DownloadFileUpdate,
|
||||
RmOptions,
|
||||
fsConstants,
|
||||
EnvironmentInfo,
|
||||
} from 'flipper-common';
|
||||
|
||||
export type FileEncoding = 'utf-8' | 'base64';
|
||||
@@ -57,7 +60,9 @@ export type RemoteServerContext = {
|
||||
path: string,
|
||||
options?: {recursive?: false} & MkdirOptions,
|
||||
): Promise<void>;
|
||||
rm(path: string, options?: RmOptions): Promise<void>;
|
||||
copyFile(src: string, dest: string, flags?: number): Promise<void>;
|
||||
constants: typeof fsConstants;
|
||||
};
|
||||
downloadFile(
|
||||
url: string,
|
||||
@@ -150,6 +155,10 @@ export interface FlipperLib {
|
||||
paths: {
|
||||
homePath: string;
|
||||
appPath: string;
|
||||
tempPath: string;
|
||||
};
|
||||
environmentInfo: {
|
||||
os: EnvironmentInfo['os'];
|
||||
};
|
||||
remoteServerContext: RemoteServerContext;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,11 @@ import {
|
||||
act as testingLibAct,
|
||||
} from '@testing-library/react';
|
||||
import {queries} from '@testing-library/dom';
|
||||
import {BundledPluginDetails, InstalledPluginDetails} from 'flipper-common';
|
||||
import {
|
||||
BundledPluginDetails,
|
||||
fsConstants,
|
||||
InstalledPluginDetails,
|
||||
} from 'flipper-common';
|
||||
|
||||
import {
|
||||
RealFlipperClient,
|
||||
@@ -388,6 +392,14 @@ export function createMockFlipperLib(options?: StartPluginOptions): FlipperLib {
|
||||
paths: {
|
||||
appPath: process.cwd(),
|
||||
homePath: `/dev/null`,
|
||||
tempPath: `/dev/null`,
|
||||
},
|
||||
environmentInfo: {
|
||||
os: {
|
||||
arch: 'Test',
|
||||
unixname: 'test',
|
||||
platform: 'linux',
|
||||
},
|
||||
},
|
||||
remoteServerContext: {
|
||||
childProcess: {
|
||||
@@ -398,7 +410,9 @@ export function createMockFlipperLib(options?: StartPluginOptions): FlipperLib {
|
||||
pathExists: jest.fn(),
|
||||
unlink: jest.fn(),
|
||||
mkdir: jest.fn(),
|
||||
rm: jest.fn(),
|
||||
copyFile: jest.fn(),
|
||||
constants: fsConstants,
|
||||
},
|
||||
downloadFile: jest.fn(),
|
||||
},
|
||||
|
||||
11
desktop/flipper-plugin/src/utils/uuid.tsx
Normal file
11
desktop/flipper-plugin/src/utils/uuid.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {v4 as uuid} from 'uuid';
|
||||
export {uuid};
|
||||
Reference in New Issue
Block a user