Share uuid

Summary: Expose uuid from flipper-common as it is required in multiple packages

Reviewed By: lblasa

Differential Revision: D36441889

fbshipit-source-id: 1fa539cb437976dbefe7d5d9a52e5e098a6402a7
This commit is contained in:
Andrey Goncharov
2022-05-18 03:13:31 -07:00
committed by Facebook GitHub Bot
parent 88bc3110a5
commit 0f038218f8
11 changed files with 24 additions and 19 deletions

View File

@@ -8,8 +8,12 @@
"types": "lib/index.d.ts", "types": "lib/index.d.ts",
"license": "MIT", "license": "MIT",
"bugs": "https://github.com/facebook/flipper/issues", "bugs": "https://github.com/facebook/flipper/issues",
"dependencies": {}, "dependencies": {
"devDependencies": {}, "uuid": "^8.3.2"
},
"devDependencies": {
"@types/uuid": "^8.3.4"
},
"peerDependencies": {}, "peerDependencies": {},
"scripts": { "scripts": {
"reset": "rimraf lib *.tsbuildinfo", "reset": "rimraf lib *.tsbuildinfo",

View File

@@ -52,6 +52,7 @@ export {
} from './utils/errors'; } from './utils/errors';
export {createControlledPromise} from './utils/controlledPromise'; export {createControlledPromise} from './utils/controlledPromise';
export * from './utils/typeUtils'; export * from './utils/typeUtils';
export * from './utils/uuid';
export * from './GK'; export * from './GK';
export * from './clientUtils'; export * from './clientUtils';
export * from './settings'; export * from './settings';

View File

@@ -7,5 +7,4 @@
* @format * @format
*/ */
import {v4 as uuid} from 'uuid'; export {v4 as uuid} from 'uuid';
export {uuid};

View File

@@ -24,12 +24,10 @@
"react-color": "^2.19.3", "react-color": "^2.19.3",
"react-element-to-jsx-string": "^14.3.4", "react-element-to-jsx-string": "^14.3.4",
"react-virtual": "^2.10.4", "react-virtual": "^2.10.4",
"string-natural-compare": "^3.0.0", "string-natural-compare": "^3.0.0"
"uuid": "^8.3.2"
}, },
"devDependencies": { "devDependencies": {
"@types/string-natural-compare": "^3.0.2", "@types/string-natural-compare": "^3.0.2",
"@types/uuid": "^8.3.4",
"jest-mock-console": "^1.2.3" "jest-mock-console": "^1.2.3"
}, },
"peerDependencies": { "peerDependencies": {

View File

@@ -137,7 +137,6 @@ export {createTablePlugin} from './utils/createTablePlugin';
export {textContent} from './utils/textContent'; export {textContent} from './utils/textContent';
import * as path from './utils/path'; import * as path from './utils/path';
export {path}; export {path};
export * from './utils/uuid';
export {safeStringify} from './utils/safeStringify'; export {safeStringify} from './utils/safeStringify';
// It's not ideal that this exists in flipper-plugin sources directly, // It's not ideal that this exists in flipper-plugin sources directly,
@@ -150,6 +149,7 @@ export {
sleep, sleep,
timeout, timeout,
createControlledPromise, createControlledPromise,
uuid,
DeviceOS, DeviceOS,
DeviceType, DeviceType,
DeviceLogEntry, DeviceLogEntry,

View File

@@ -11,13 +11,13 @@
import * as path from './utils/path'; import * as path from './utils/path';
export {path}; export {path};
export * from './utils/uuid';
export {safeStringify} from './utils/safeStringify'; export {safeStringify} from './utils/safeStringify';
export { export {
sleep, sleep,
timeout, timeout,
createControlledPromise, createControlledPromise,
uuid,
ServerAddOn, ServerAddOn,
ServerAddOnPluginConnection, ServerAddOnPluginConnection,
FlipperServerForServerAddOn, FlipperServerForServerAddOn,

View File

@@ -10,7 +10,7 @@
import React, {useMemo} from 'react'; import React, {useMemo} from 'react';
import {Children, cloneElement, createContext, useContext} from 'react'; import {Children, cloneElement, createContext, useContext} from 'react';
import reactElementToJSXString from 'react-element-to-jsx-string'; import reactElementToJSXString from 'react-element-to-jsx-string';
import {v4 as uuid} from 'uuid'; import {uuid} from 'flipper-common';
export type InteractionReport = { export type InteractionReport = {
// Duration of the event handler itself, not including any time the promise handler might have been pending // Duration of the event handler itself, not including any time the promise handler might have been pending

View File

@@ -39,7 +39,6 @@
"serialize-error": "^8.1.0", "serialize-error": "^8.1.0",
"split2": "^4.1.0", "split2": "^4.1.0",
"tmp": "^0.2.1", "tmp": "^0.2.1",
"uuid": "^8.3.2",
"which": "^2.0.2", "which": "^2.0.2",
"ws": "^8.5.0", "ws": "^8.5.0",
"xdg-basedir": "^4.0.0" "xdg-basedir": "^4.0.0"

View File

@@ -7,11 +7,10 @@
* @format * @format
*/ */
import {FlipperServerCommands, FlipperServerEvents} from 'flipper-common'; import {FlipperServerCommands, FlipperServerEvents, uuid} from 'flipper-common';
import {pathExists} from 'fs-extra'; import {pathExists} from 'fs-extra';
import {promises, createWriteStream, ReadStream} from 'fs'; import {promises, createWriteStream, ReadStream} from 'fs';
import axios from 'axios'; import axios from 'axios';
import {v4 as uuid} from 'uuid';
const {unlink} = promises; const {unlink} = promises;

View File

@@ -10,9 +10,15 @@
import axios from 'axios'; import axios from 'axios';
import MemoryStream from 'memorystream'; import MemoryStream from 'memorystream';
import {dirSync} from 'tmp'; import {dirSync} from 'tmp';
import * as uuid from 'uuid'; import * as flipperCommon from 'flipper-common';
import {commandDownloadFileStartFactory} from '../DownloadFile'; import {commandDownloadFileStartFactory} from '../DownloadFile';
// https://stackoverflow.com/a/63374190
jest.mock('flipper-common', () => ({
__esModule: true,
...jest.requireActual('flipper-common'),
}));
describe('commands', () => { describe('commands', () => {
describe('DownloadFile', () => { describe('DownloadFile', () => {
let commandDownloadFileStart: ReturnType< let commandDownloadFileStart: ReturnType<
@@ -60,7 +66,7 @@ describe('commands', () => {
const fakeDownloadURL = 'https://flipper.rocks'; const fakeDownloadURL = 'https://flipper.rocks';
const fakeUuid = 'flipper42'; const fakeUuid = 'flipper42';
jest.spyOn(uuid, 'v4').mockImplementation(() => fakeUuid); jest.spyOn(flipperCommon, 'uuid').mockImplementation(() => fakeUuid);
const downloadFileDescriptor = await commandDownloadFileStart( const downloadFileDescriptor = await commandDownloadFileStart(
fakeDownloadURL, fakeDownloadURL,
@@ -135,7 +141,7 @@ describe('commands', () => {
const fakeDownloadURL = 'https://flipper.rocks'; const fakeDownloadURL = 'https://flipper.rocks';
const fakeUuid = 'flipper42'; const fakeUuid = 'flipper42';
jest.spyOn(uuid, 'v4').mockImplementation(() => fakeUuid); jest.spyOn(flipperCommon, 'uuid').mockImplementation(() => fakeUuid);
await commandDownloadFileStart(fakeDownloadURL, dest); await commandDownloadFileStart(fakeDownloadURL, dest);
@@ -177,7 +183,7 @@ describe('commands', () => {
const fakeDownloadURL = 'https://flipper.rocks'; const fakeDownloadURL = 'https://flipper.rocks';
const fakeUuid = 'flipper42'; const fakeUuid = 'flipper42';
jest.spyOn(uuid, 'v4').mockImplementation(() => fakeUuid); jest.spyOn(flipperCommon, 'uuid').mockImplementation(() => fakeUuid);
// We provide an invalid path to force write stream to fail // We provide an invalid path to force write stream to fail
await commandDownloadFileStart(fakeDownloadURL, ''); await commandDownloadFileStart(fakeDownloadURL, '');

View File

@@ -12,8 +12,7 @@ import iosUtil from './iOSContainerUtility';
import child_process from 'child_process'; import child_process from 'child_process';
import type {IOSDeviceParams} from 'flipper-common'; import type {IOSDeviceParams} from 'flipper-common';
import {DeviceType} from 'flipper-common'; import {DeviceType, uuid} from 'flipper-common';
import {v1 as uuid} from 'uuid';
import path from 'path'; import path from 'path';
import {exec, execFile} from 'promisify-child-process'; import {exec, execFile} from 'promisify-child-process';
import {getFlipperServerConfig} from '../../FlipperServerConfig'; import {getFlipperServerConfig} from '../../FlipperServerConfig';