File tree Expand file tree Collapse file tree 5 files changed +24
-10
lines changed
packages/cli/src/commands/link Expand file tree Collapse file tree 5 files changed +24
-10
lines changed Original file line number Diff line number Diff line change 11import { func as link } from '../link' ;
22import loadConfig from '../../../tools/config' ;
33import makeHook from '../makeHook' ;
4- jest . mock ( 'chalk' , ( ) => ( { grey : str => str , bold : str => str } ) ) ;
4+ jest . mock ( 'chalk' , ( ) => ( {
5+ grey : jest . fn ( ) ,
6+ bold : jest . fn ( ) ,
7+ dim : { underline : jest . fn ( ) } ,
8+ } ) ) ;
59jest . mock ( '../../../tools/config' ) ;
610jest . mock ( '../makeHook' , ( ) => {
711 return jest . fn ( ( ) => {
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import linkDependency from './linkDependency';
1515import linkAssets from './linkAssets' ;
1616import linkAll from './linkAll' ;
1717import makeHook from './makeHook' ;
18+ import printDeprecationWarning from './printDeprecationWarning' ;
1819
1920type FlagsType = {
2021 platforms ?: Array < string > ;
@@ -53,6 +54,8 @@ async function link(
5354 return linkAll ( ctx , { linkDeps : opts . all , linkAssets : true } ) ;
5455 }
5556
57+ printDeprecationWarning ( 'react-native link [packageName]' ) ;
58+
5659 // Trim the version / tag out of the package name (eg. package@latest)
5760 const packageName = rawPackageName . replace ( / ^ ( .+ ?) ( @ .+ ?) $ / gi, '$1' ) ;
5861
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import {Config} from '@react-native-community/cli-types';
66import linkAssets from './linkAssets' ;
77import linkDependency from './linkDependency' ;
88import makeHook from './makeHook' ;
9+ import printDeprecationWarning from './printDeprecationWarning' ;
910
1011const dedupeAssets = ( assets : Array < string > ) : Array < string > =>
1112 uniqBy ( assets , asset => path . basename ( asset ) ) ;
@@ -17,16 +18,8 @@ type Options = {
1718
1819async function linkAll ( config : Config , options : Options ) {
1920 if ( options . linkDeps ) {
21+ printDeprecationWarning ( 'react-native link --all' ) ;
2022 logger . debug ( 'Linking all dependencies' ) ;
21- logger . info (
22- `Linking dependencies using "${ chalk . bold (
23- 'link' ,
24- ) } " command is now legacy and most likely unnecessary. We encourage you to try ${ chalk . bold (
25- 'autolinking' ,
26- ) } that comes with React Native v0.60 default template. Autolinking happens at build time – during CocoaPods install or Gradle install phase. More information: ${ chalk . dim . underline (
27- 'https://github.com/react-native-community/cli/blob/master/docs/autolinking.md' ,
28- ) } `,
29- ) ;
3023
3124 for ( let key in config . dependencies ) {
3225 const dependency = config . dependencies [ key ] ;
Original file line number Diff line number Diff line change 1+ import chalk from 'chalk' ;
2+ import { logger } from '@react-native-community/cli-tools' ;
3+
4+ export default function printDeprecationWarning ( command : string ) {
5+ logger . warn (
6+ `Calling ${ chalk . bold (
7+ command ,
8+ ) } is deprecated in favor of autolinking. It will be removed in the next major release.\nAutolinking documentation: ${ chalk . dim . underline (
9+ 'https://github.com/react-native-community/cli/blob/master/docs/autolinking.md' ,
10+ ) } `,
11+ ) ;
12+ }
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import {
1717} from '@react-native-community/cli-types' ;
1818import getPlatformName from './getPlatformName' ;
1919import makeHook from './makeHook' ;
20+ import printDeprecationWarning from './printDeprecationWarning' ;
2021
2122type Flags = {
2223 platforms ?: Array < string > ;
@@ -29,6 +30,7 @@ const unlinkDependency = (
2930 packageName : string ,
3031 otherDependencies : Array < Dependency > ,
3132) => {
33+ printDeprecationWarning ( 'react-native unlink [packageName]' ) ;
3234 Object . keys ( platforms || { } ) . forEach ( platform => {
3335 const projectConfig : AndroidProjectConfig | IOSProjectConfig =
3436 project [ platform ] ;
You can’t perform that action at this time.
0 commit comments