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:
Andrey Goncharov
2021-12-10 06:34:37 -08:00
committed by Facebook GitHub Bot
parent adb2573a1f
commit c96558a524
15 changed files with 166 additions and 6 deletions

View File

@@ -21,6 +21,7 @@ export {sleep} from './utils/sleep';
export {timeout} from './utils/timeout';
export {isTest} from './utils/isTest';
export {assertNever} from './utils/assertNever';
export {fsConstants} from './utils/fsConstants';
export {
logPlatformSuccessRate,
reportPlatformFailures,

View File

@@ -140,6 +140,7 @@ export type FlipperServerCommands = {
path: string,
options?: {recursive?: boolean} & MkdirOptions,
) => Promise<string | void>;
'node-api-fs-rm': (path: string, options?: RmOptions) => Promise<void>;
'node-api-fs-copyFile': (
src: string,
dest: string,
@@ -332,6 +333,10 @@ export interface MkdirOptions {
mode?: string | number;
}
export interface RmOptions {
maxRetries?: number;
}
export interface DownloadFileStartOptions {
method?: 'GET' | 'POST';
timeout?: number;

View File

@@ -69,6 +69,19 @@ export type ProcessConfig = {
launcherEnabled: boolean;
};
export type Platform =
| 'aix'
| 'android'
| 'darwin'
| 'freebsd'
| 'haiku'
| 'linux'
| 'openbsd'
| 'sunos'
| 'win32'
| 'cygwin'
| 'netbsd';
export type EnvironmentInfo = {
processId: number;
isProduction: boolean;
@@ -77,7 +90,7 @@ export type EnvironmentInfo = {
appVersion: string;
os: {
arch: string;
platform: NodeJS.Platform;
platform: Platform;
unixname: string;
};
versions: {

View File

@@ -0,0 +1,67 @@
/**
* 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
*/
// https://github.com/nodejs/node/blob/b66a75a3a4361614dde9bc1a52d7e9021b4efc26/typings/internalBinding/constants.d.ts
export const fsConstants = {
UV_FS_SYMLINK_DIR: 1,
UV_FS_SYMLINK_JUNCTION: 2,
O_RDONLY: 0,
O_WRONLY: 1,
O_RDWR: 2,
UV_DIRENT_UNKNOWN: 0,
UV_DIRENT_FILE: 1,
UV_DIRENT_DIR: 2,
UV_DIRENT_LINK: 3,
UV_DIRENT_FIFO: 4,
UV_DIRENT_SOCKET: 5,
UV_DIRENT_CHAR: 6,
UV_DIRENT_BLOCK: 7,
S_IFMT: 61440,
S_IFREG: 32768,
S_IFDIR: 16384,
S_IFCHR: 8192,
S_IFBLK: 24576,
S_IFIFO: 4096,
S_IFLNK: 40960,
S_IFSOCK: 49152,
O_CREAT: 512,
O_EXCL: 2048,
UV_FS_O_FILEMAP: 0,
O_NOCTTY: 131072,
O_TRUNC: 1024,
O_APPEND: 8,
O_DIRECTORY: 1048576,
O_NOFOLLOW: 256,
O_SYNC: 128,
O_DSYNC: 4194304,
O_SYMLINK: 2097152,
O_NONBLOCK: 4,
S_IRWXU: 448,
S_IRUSR: 256,
S_IWUSR: 128,
S_IXUSR: 64,
S_IRWXG: 56,
S_IRGRP: 32,
S_IWGRP: 16,
S_IXGRP: 8,
S_IRWXO: 7,
S_IROTH: 4,
S_IWOTH: 2,
S_IXOTH: 1,
F_OK: 0,
R_OK: 4,
W_OK: 2,
X_OK: 1,
UV_FS_COPYFILE_EXCL: 1,
COPYFILE_EXCL: 1,
UV_FS_COPYFILE_FICLONE: 2,
COPYFILE_FICLONE: 2,
UV_FS_COPYFILE_FICLONE_FORCE: 4,
COPYFILE_FICLONE_FORCE: 4,
};