diff --git a/packages/cli/src/commands/server/copyToClipBoard.ts b/packages/cli/src/commands/server/copyToClipBoard.ts deleted file mode 100644 index be37938ef..000000000 --- a/packages/cli/src/commands/server/copyToClipBoard.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * 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 {spawn} from 'child_process'; -import {logger} from '@react-native-community/cli-tools'; - -import path from 'path'; -import fs from 'fs'; - -const xsel = path.join(__dirname, 'external/xsel'); -try { - fs.chmodSync(xsel, '0755'); -} catch (e) { - logger.warn(`Failed to chmod xsel: ${e.message}`); -} - -/** - * Copy the content to host system clipboard. - */ -function copyToClipBoard(content: string) { - switch (process.platform) { - case 'darwin': { - const child = spawn('pbcopy', []); - child.stdin.end(Buffer.from(content, 'utf8')); - return true; - } - case 'win32': { - const child = spawn('clip', []); - child.stdin.end(Buffer.from(content, 'utf8')); - return true; - } - case 'linux': { - const child = spawn(xsel, ['--clipboard', '--input']); - child.stdin.end(Buffer.from(content, 'utf8')); - return true; - } - default: - return false; - } -} - -export default copyToClipBoard; diff --git a/packages/cli/src/commands/server/external/xsel b/packages/cli/src/commands/server/external/xsel deleted file mode 100755 index a6b2fd3d5..000000000 Binary files a/packages/cli/src/commands/server/external/xsel and /dev/null differ diff --git a/packages/cli/src/commands/server/middleware/MiddlewareManager.ts b/packages/cli/src/commands/server/middleware/MiddlewareManager.ts index 915944f32..3ced8f812 100644 --- a/packages/cli/src/commands/server/middleware/MiddlewareManager.ts +++ b/packages/cli/src/commands/server/middleware/MiddlewareManager.ts @@ -11,9 +11,7 @@ import errorhandler from 'errorhandler'; import {Server as WebSocketServer} from 'ws'; import serveStatic from 'serve-static'; import {debuggerUIMiddleware} from '@react-native-community/cli-debugger-ui'; - import indexPageMiddleware from './indexPage'; -import copyToClipBoardMiddleware from './copyToClipBoardMiddleware'; import getSecurityHeadersMiddleware from './getSecurityHeadersMiddleware'; import loadRawBodyMiddleware from './loadRawBodyMiddleware'; import openStackFrameInEditorMiddleware from './openStackFrameInEditorMiddleware'; @@ -48,7 +46,6 @@ export default class MiddlewareManager { .use('/debugger-ui', debuggerUIMiddleware()) .use(openStackFrameInEditorMiddleware(this.options)) .use(openURLMiddleware) - .use(copyToClipBoardMiddleware) .use(statusPageMiddleware) .use(systraceProfileMiddleware) .use(indexPageMiddleware) diff --git a/packages/cli/src/commands/server/middleware/copyToClipBoardMiddleware.ts b/packages/cli/src/commands/server/middleware/copyToClipBoardMiddleware.ts deleted file mode 100644 index d7665c1f5..000000000 --- a/packages/cli/src/commands/server/middleware/copyToClipBoardMiddleware.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * 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. - * - */ -import http from 'http'; -import copyToClipBoard from '../copyToClipBoard'; -import {logger} from '@react-native-community/cli-tools'; - -/** - * Handle the request from JS to copy contents onto host system clipboard. - * This is only supported on Mac for now. - */ -export default function copyMiddleware( - req: http.IncomingMessage, - res: http.ServerResponse, - next: (err?: any) => void, -) { - if (req.url === '/copy-to-clipboard') { - const ret = copyToClipBoard( - (req as http.IncomingMessage & {rawBody: string}).rawBody, - ); - if (!ret) { - logger.warn('Copy button is not supported on this platform!'); - } - res.end('OK'); - } else { - next(); - } -}