diff --git a/packages/cli/README.md b/packages/cli/README.md index f4158203af..18289bedb6 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -8,7 +8,6 @@ CLI comes with a set of commands and flags you can pass to them. - [`bundle`](#bundle) - [`dependencies`](#dependencies) -- [`eject`](#eject) - [`info`](#info) - [`install`](#install) - [`library`](#library) @@ -29,8 +28,6 @@ _Note: This document is still under development and doesn't represent the full A ### `dependencies` -### `eject` - ### `info` ### `install` diff --git a/packages/cli/src/commands/eject/eject.js b/packages/cli/src/commands/eject/eject.js deleted file mode 100644 index 32144fbd72..0000000000 --- a/packages/cli/src/commands/eject/eject.js +++ /dev/null @@ -1,97 +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 path from 'path'; -import fs from 'fs'; -import copyProjectTemplateAndReplace from '../../tools/generator/copyProjectTemplateAndReplace'; -import logger from '../../tools/logger'; - -/** - * The eject command re-creates the `android` and `ios` native folders. Because native code can be - * difficult to maintain, this new script allows an `app.json` to be defined for the project, which - * is used to configure the native app. - * - * The `app.json` config may contain the following keys: - * - * - `name` - The short name used for the project, should be TitleCase - * - `displayName` - The app's name on the home screen - */ - -function eject() { - const doesIOSExist = fs.existsSync(path.resolve('ios')); - const doesAndroidExist = fs.existsSync(path.resolve('android')); - if (doesIOSExist && doesAndroidExist) { - logger.error( - 'Both the iOS and Android folders already exist! Please delete `ios` and/or `android` ' + - 'before ejecting.', - ); - process.exit(1); - } - - let appConfig = null; - try { - appConfig = require(path.resolve('app.json')); - } catch (e) { - logger.error( - 'Eject requires an `app.json` config file to be located at ' + - `${path.resolve( - 'app.json', - )}, and it must at least specify a \`name\` for the project ` + - "name, and a `displayName` for the app's home screen label.", - ); - process.exit(1); - } - - const appName = appConfig.name; - if (!appName) { - logger.error( - 'App `name` must be defined in the `app.json` config file to define the project name. ' + - 'It must not contain any spaces or dashes.', - ); - process.exit(1); - } - - const displayName = appConfig.displayName; - if (!displayName) { - logger.error( - 'App `displayName` must be defined in the `app.json` config file, to define the label ' + - 'of the app on the home screen.', - ); - process.exit(1); - } - - const templateOptions = {displayName}; - - if (!doesIOSExist) { - logger.info('Generating the iOS folder.'); - copyProjectTemplateAndReplace( - path.resolve('node_modules', 'react-native', 'template', 'ios'), - path.resolve('ios'), - appName, - templateOptions, - ); - } - - if (!doesAndroidExist) { - logger.info('Generating the Android folder.'); - copyProjectTemplateAndReplace( - path.resolve('node_modules', 'react-native', 'template', 'android'), - path.resolve('android'), - appName, - templateOptions, - ); - } -} - -export default { - name: 'eject', - description: 'Re-create the iOS and Android folders and native code', - func: eject, - options: [], -}; diff --git a/packages/cli/src/commands/index.js b/packages/cli/src/commands/index.js index fded7f655f..04d8820979 100644 --- a/packages/cli/src/commands/index.js +++ b/packages/cli/src/commands/index.js @@ -19,7 +19,6 @@ import runAndroid from './runAndroid/runAndroid'; import library from './library/library'; import bundle from './bundle/bundle'; import ramBundle from './bundle/ramBundle'; -import eject from './eject/eject'; import link from './link/link'; import unlink from './link/unlink'; import install from './install/install'; @@ -40,7 +39,6 @@ const loadLocalCommands: Array = [ library, bundle, ramBundle, - eject, link, unlink, install, diff --git a/packages/cli/src/commands/link/link.js b/packages/cli/src/commands/link/link.js index b4538c9cea..c57f950ac2 100644 --- a/packages/cli/src/commands/link/link.js +++ b/packages/cli/src/commands/link/link.js @@ -19,7 +19,6 @@ import getProjectConfig from './getProjectConfig'; import linkDependency from './linkDependency'; import linkAssets from './linkAssets'; import linkAll from './linkAll'; -import findReactNativeScripts from '../../tools/findReactNativeScripts'; import getPlatforms, {getPlatformName} from '../../tools/getPlatforms'; type FlagsType = { @@ -59,19 +58,6 @@ function link([rawPackageName]: Array, ctx: ContextT, opts: FlagsType) { ); return Promise.reject(err); } - const hasProjectConfig = Object.keys(platforms).reduce( - (acc, key) => acc || key in project, - false, - ); - if (!hasProjectConfig && findReactNativeScripts()) { - throw new Error( - '`react-native link [package]` can not be used in Create React Native App projects. ' + - 'If you need to include a library that relies on custom native code, ' + - 'you might have to eject first. ' + - 'See https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md ' + - 'for more information.', - ); - } if (rawPackageName === undefined) { logger.debug( diff --git a/packages/cli/src/tools/findReactNativeScripts.js b/packages/cli/src/tools/findReactNativeScripts.js deleted file mode 100644 index 876b9dcae6..0000000000 --- a/packages/cli/src/tools/findReactNativeScripts.js +++ /dev/null @@ -1,26 +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 - * @flow strict - */ - -import path from 'path'; -import fs from 'fs'; - -function findReactNativeScripts(): ?string { - const executablePath = path.resolve( - 'node_modules', - '.bin', - 'react-native-scripts', - ); - if (fs.existsSync(executablePath)) { - return executablePath; - } - return null; -} - -export default findReactNativeScripts;