diff --git a/commitlint.config.js b/commitlint.config.js deleted file mode 100644 index 84dcb122a..000000000 --- a/commitlint.config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - extends: ['@commitlint/config-conventional'], -}; diff --git a/packages/cli/package.json b/packages/cli/package.json index fff93c214..a287f61b7 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -28,7 +28,6 @@ "errorhandler": "^1.5.0", "escape-string-regexp": "^1.0.5", "execa": "^1.0.0", - "fs-extra": "^1.0.0", "glob": "^7.1.1", "graceful-fs": "^4.1.3", "inquirer": "^3.0.6", diff --git a/packages/cli/src/commands/link/android/copyAssets.js b/packages/cli/src/commands/link/android/copyAssets.js index 8e894b7d6..81f4ad58a 100644 --- a/packages/cli/src/commands/link/android/copyAssets.js +++ b/packages/cli/src/commands/link/android/copyAssets.js @@ -4,10 +4,10 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @format + * @flow */ -import fs from 'fs-extra'; +import fs from 'fs'; import path from 'path'; import groupFilesByType from '../groupFilesByType'; @@ -17,11 +17,14 @@ import groupFilesByType from '../groupFilesByType'; * For now, the only types of files that are handled are: * - Fonts (otf, ttf) - copied to targetPath/fonts under original name */ -export default function copyAssetsAndroid(files, project) { +export default function copyAssetsAndroid( + files: Array, + project: {assetsPath: string}, +) { const assets = groupFilesByType(files); (assets.font || []).forEach(asset => - fs.copySync( + fs.copyFileSync( asset, path.join(project.assetsPath, 'fonts', path.basename(asset)), ), diff --git a/packages/cli/src/commands/link/android/fs.js b/packages/cli/src/commands/link/android/fs.js deleted file mode 100644 index 26ecbdae0..000000000 --- a/packages/cli/src/commands/link/android/fs.js +++ /dev/null @@ -1,17 +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 fs from 'fs-extra'; - -exports.readFile = file => () => fs.readFileSync(file, 'utf8'); - -exports.writeFile = (file, content) => - content - ? fs.writeFileSync(file, content, 'utf8') - : c => fs.writeFileSync(file, c, 'utf8'); diff --git a/packages/cli/src/commands/link/android/index.js b/packages/cli/src/commands/link/android/index.js index df7ae3332..26583d7ff 100644 --- a/packages/cli/src/commands/link/android/index.js +++ b/packages/cli/src/commands/link/android/index.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @format + * @flow */ import isInstalled from './isInstalled'; diff --git a/packages/cli/src/commands/link/android/unlinkAssets.js b/packages/cli/src/commands/link/android/unlinkAssets.js index ff1f2e869..e1b39fd1d 100644 --- a/packages/cli/src/commands/link/android/unlinkAssets.js +++ b/packages/cli/src/commands/link/android/unlinkAssets.js @@ -7,7 +7,7 @@ * @format */ -import fs from 'fs-extra'; +import fs from 'fs'; import path from 'path'; import groupFilesByType from '../groupFilesByType'; diff --git a/packages/cli/src/commands/link/groupFilesByType.js b/packages/cli/src/commands/link/groupFilesByType.js index f40830451..cc9a723e8 100644 --- a/packages/cli/src/commands/link/groupFilesByType.js +++ b/packages/cli/src/commands/link/groupFilesByType.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @format + * @flow */ import {groupBy} from 'lodash'; @@ -31,6 +31,6 @@ mime.define({ * Given an array ['fonts/a.ttf', 'images/b.jpg'], * the returned object will be: {font: ['fonts/a.ttf'], image: ['images/b.jpg']} */ -export default function groupFilesByType(assets) { +export default function groupFilesByType(assets: Array) { return groupBy(assets, type => mime.lookup(type).split('/')[0]); } diff --git a/packages/cli/src/commands/link/ios/copyAssets.js b/packages/cli/src/commands/link/ios/copyAssets.js index 58dbec83c..cf9fcd796 100644 --- a/packages/cli/src/commands/link/ios/copyAssets.js +++ b/packages/cli/src/commands/link/ios/copyAssets.js @@ -7,7 +7,7 @@ * @format */ -import fs from 'fs-extra'; +import fs from 'fs'; import path from 'path'; import xcode from 'xcode'; import groupFilesByType from '../groupFilesByType'; diff --git a/packages/cli/src/commands/link/ios/unlinkAssets.js b/packages/cli/src/commands/link/ios/unlinkAssets.js index 4843dbd28..546e1d371 100644 --- a/packages/cli/src/commands/link/ios/unlinkAssets.js +++ b/packages/cli/src/commands/link/ios/unlinkAssets.js @@ -6,7 +6,7 @@ * */ -import fs from 'fs-extra'; +import fs from 'fs'; import path from 'path'; import xcode from 'xcode'; import {difference} from 'lodash'; diff --git a/packages/cli/src/commands/server/jsPackagerClient.js b/packages/cli/src/commands/server/jsPackagerClient.js deleted file mode 100644 index 3f051df4b..000000000 --- a/packages/cli/src/commands/server/jsPackagerClient.js +++ /dev/null @@ -1,121 +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 WebSocket from 'ws'; -import logger from '../../tools/logger'; -import MessageSocket from './messageSocket'; - -const PROTOCOL_VERSION = 2; -const TARGET_SERVER = 'server'; - -function getMessageId() { - return `${Date.now()}:${Math.random()}`; -} - -class JsPackagerClient { - constructor(url) { - this.ws = new WebSocket(url); - this.msgCallbacks = new Map(); - - this.openPromise = new Promise((resolve, reject) => { - this.ws.on('error', error => reject(error)); - this.ws.on('open', resolve); - }); - - this.ws.on('message', (data, flags) => { - const message = MessageSocket.parseMessage(data, flags.binary); - const msgCallback = this.msgCallbacks.get(message.id); - if (message === undefined || message.id === undefined) { - // gracefully ignore wrong messages or broadcasts - } else if (msgCallback === undefined) { - logger.warn(`Response with non-existing message id: '${message.id}'`); - } else if (message.error === undefined) { - msgCallback.resolve(message.result); - } else { - msgCallback.reject(message.error); - } - }); - } - - sendRequest(method, target, params) { - return this.openPromise.then( - () => - new Promise((resolve, reject) => { - const messageId = getMessageId(); - this.msgCallbacks.set(messageId, {resolve, reject}); - this.ws.send( - JSON.stringify({ - version: PROTOCOL_VERSION, - target, - method, - id: messageId, - params, - }), - error => { - if (error !== undefined) { - this.msgCallbacks.delete(messageId); - reject(error); - } - }, - ); - }), - ); - } - - sendNotification(method, target, params) { - return this.openPromise.then( - () => - new Promise((resolve, reject) => { - this.ws.send( - JSON.stringify({ - version: PROTOCOL_VERSION, - target, - method, - params, - }), - error => { - if (error !== undefined) { - reject(error); - } else { - resolve(); - } - }, - ); - }), - ); - } - - sendBroadcast(method, params) { - return this.sendNotification(method, undefined, params); - } - - getPeers() { - return new Promise((resolve, reject) => { - this.sendRequest('getpeers', TARGET_SERVER, undefined).then(response => { - if (!(response instanceof Map)) { - reject( - new Error( - `Results received from server are of wrong format:\n${JSON.stringify( - response, - )}`, - ), - ); - } else { - resolve(response); - } - }, reject); - }); - } - - getId() { - return this.sendRequest('getid', TARGET_SERVER, undefined); - } -} - -export default JsPackagerClient;