diff --git a/docs/commands.md b/docs/commands.md index f1a7a3246..dfdcd835f 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -7,7 +7,6 @@ React Native CLI comes with following commands: - [`init`](#init) - [`info`](#info) - [`install`](#install) -- [`library`](#library) - [`link`](#link) - [`log-android`](#log-android) - [`log-ios`](#log-ios) @@ -188,20 +187,6 @@ react-native install Installs single package from npm and then links native dependencies. If `install` detects `yarn.lock` in your project, it will use Yarn as package manager. Otherwise `npm` will be used. -### `library` - -Usage: - -```sh -react-native library -``` - -Generates a native library bridge. - -#### `--name ` - -Name of the library to generate. - ### `link` > Will be replaced by [autolinking](./autolinking.md) soon. diff --git a/packages/cli/src/commands/index.js b/packages/cli/src/commands/index.js index c76f1f2c9..6c56740c4 100644 --- a/packages/cli/src/commands/index.js +++ b/packages/cli/src/commands/index.js @@ -4,7 +4,6 @@ import {type CommandT} from 'types'; import server from './server/server'; -import library from './library/library'; import bundle from './bundle/bundle'; import ramBundle from './bundle/ramBundle'; import link from './link/link'; @@ -18,7 +17,6 @@ import init from './init'; export default ([ server, - library, bundle, ramBundle, link, diff --git a/packages/cli/src/commands/library/library.js b/packages/cli/src/commands/library/library.js deleted file mode 100644 index 0aa1b9fab..000000000 --- a/packages/cli/src/commands/library/library.js +++ /dev/null @@ -1,78 +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'; -import path from 'path'; -import copyAndReplace from '../../tools/copyAndReplace'; -import isValidPackageName from '../../tools/isValidPackageName'; -import walk from '../../tools/walk'; -import {logger} from '@react-native-community/cli-tools'; - -/** - * Creates a new native library with the given name - */ -async function library(argv, ctx, args) { - if (!isValidPackageName(args.name)) { - throw new Error( - `${args.name} is not a valid name for a project. Please use a valid ` + - 'identifier name (alphanumeric).', - ); - } - - const libraries = path.resolve(ctx.root, 'Libraries'); - const libraryDest = path.resolve(libraries, args.name); - const source = path.resolve( - 'node_modules', - 'react-native', - 'Libraries', - 'Sample', - ); - - if (!fs.existsSync(libraries)) { - fs.mkdirSync(libraries); - } - - if (fs.existsSync(libraryDest)) { - throw new Error(`Library already exists in ${libraryDest}`); - } - - walk(source).forEach(f => { - if ( - f.indexOf('project.xcworkspace') !== -1 || - f.indexOf('.xcodeproj/xcuserdata') !== -1 - ) { - return; - } - - const dest = path.relative( - source, - f.replace(/Sample/g, args.name).replace(/^_/, '.'), - ); - copyAndReplace(path.resolve(source, f), path.resolve(libraryDest, dest), { - Sample: args.name, - }); - }); - - logger.info(`Created library in ${libraryDest}. -Now it needs to be linked in Xcode: -https://facebook.github.io/react-native/docs/linking-libraries-ios.html#content`); -} - -export default { - name: 'new-library', - func: library, - description: 'generates a native library bridge', - options: [ - { - name: '--name ', - description: 'name of the library to generate', - default: null, - }, - ], -};