From f85b4afc52d96851079674285fa31d3ff9f2cb1a Mon Sep 17 00:00:00 2001 From: Kacper Wiszczuk Date: Wed, 4 Mar 2020 22:13:01 +0100 Subject: [PATCH 1/4] imp: Add deprecation messages for linking --- packages/cli/src/commands/link/link.ts | 2 ++ .../cli/src/commands/link/printDeprecationWarning.ts | 12 ++++++++++++ packages/cli/src/commands/link/unlink.ts | 2 ++ 3 files changed, 16 insertions(+) create mode 100644 packages/cli/src/commands/link/printDeprecationWarning.ts diff --git a/packages/cli/src/commands/link/link.ts b/packages/cli/src/commands/link/link.ts index d1cf9bba7..9af1b39bc 100644 --- a/packages/cli/src/commands/link/link.ts +++ b/packages/cli/src/commands/link/link.ts @@ -15,6 +15,7 @@ import linkDependency from './linkDependency'; import linkAssets from './linkAssets'; import linkAll from './linkAll'; import makeHook from './makeHook'; +import printDeprecationWarning from './printDeprecationWarning'; type FlagsType = { platforms?: Array; @@ -32,6 +33,7 @@ async function link( ctx: Config, opts: FlagsType, ) { + printDeprecationWarning('link'); let platforms = ctx.platforms; let project = ctx.project; diff --git a/packages/cli/src/commands/link/printDeprecationWarning.ts b/packages/cli/src/commands/link/printDeprecationWarning.ts new file mode 100644 index 000000000..3ff1c2c05 --- /dev/null +++ b/packages/cli/src/commands/link/printDeprecationWarning.ts @@ -0,0 +1,12 @@ +import chalk from 'chalk'; +import {logger} from '@react-native-community/cli-tools'; + +export default function printDeprecationWarning(command: string) { + logger.warn( + `${chalk.bold( + `react-native ${command}`, + )} command is deprecated in favour of autolinking feature and it will be removed in the next major release. You can find more information about it in the documentation: ${chalk.bold( + 'https://github.com/react-native-community/cli/blob/master/docs/autolinking.md', + )}`, + ); +} diff --git a/packages/cli/src/commands/link/unlink.ts b/packages/cli/src/commands/link/unlink.ts index 59759d905..8793d08b1 100644 --- a/packages/cli/src/commands/link/unlink.ts +++ b/packages/cli/src/commands/link/unlink.ts @@ -17,6 +17,7 @@ import { } from '@react-native-community/cli-types'; import getPlatformName from './getPlatformName'; import makeHook from './makeHook'; +import printDeprecationWarning from './printDeprecationWarning'; type Flags = { platforms?: Array; @@ -29,6 +30,7 @@ const unlinkDependency = ( packageName: string, otherDependencies: Array, ) => { + printDeprecationWarning('unlink'); Object.keys(platforms || {}).forEach(platform => { const projectConfig: AndroidProjectConfig | IOSProjectConfig = project[platform]; From cdeb386fc2265bd1ab04f903dfed8cd9197cdb7d Mon Sep 17 00:00:00 2001 From: Kacper Wiszczuk Date: Wed, 4 Mar 2020 22:30:08 +0100 Subject: [PATCH 2/4] Correct messages --- packages/cli/src/commands/link/link.ts | 3 ++- packages/cli/src/commands/link/linkAll.ts | 11 ++--------- .../cli/src/commands/link/printDeprecationWarning.ts | 6 +++--- packages/cli/src/commands/link/unlink.ts | 2 +- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/packages/cli/src/commands/link/link.ts b/packages/cli/src/commands/link/link.ts index 9af1b39bc..84aefcb1d 100644 --- a/packages/cli/src/commands/link/link.ts +++ b/packages/cli/src/commands/link/link.ts @@ -33,7 +33,6 @@ async function link( ctx: Config, opts: FlagsType, ) { - printDeprecationWarning('link'); let platforms = ctx.platforms; let project = ctx.project; @@ -55,6 +54,8 @@ async function link( return linkAll(ctx, {linkDeps: opts.all, linkAssets: true}); } + printDeprecationWarning('react-native link [packageName]'); + // Trim the version / tag out of the package name (eg. package@latest) const packageName = rawPackageName.replace(/^(.+?)(@.+?)$/gi, '$1'); diff --git a/packages/cli/src/commands/link/linkAll.ts b/packages/cli/src/commands/link/linkAll.ts index 3ff6f37f5..184ae4fd4 100644 --- a/packages/cli/src/commands/link/linkAll.ts +++ b/packages/cli/src/commands/link/linkAll.ts @@ -6,6 +6,7 @@ import {Config} from '@react-native-community/cli-types'; import linkAssets from './linkAssets'; import linkDependency from './linkDependency'; import makeHook from './makeHook'; +import printDeprecationWarning from './printDeprecationWarning'; const dedupeAssets = (assets: Array): Array => uniqBy(assets, asset => path.basename(asset)); @@ -17,16 +18,8 @@ type Options = { async function linkAll(config: Config, options: Options) { if (options.linkDeps) { + printDeprecationWarning('react-native link --all'); logger.debug('Linking all dependencies'); - logger.info( - `Linking dependencies using "${chalk.bold( - 'link', - )}" command is now legacy and most likely unnecessary. We encourage you to try ${chalk.bold( - 'autolinking', - )} 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( - 'https://github.com/react-native-community/cli/blob/master/docs/autolinking.md', - )}`, - ); for (let key in config.dependencies) { const dependency = config.dependencies[key]; diff --git a/packages/cli/src/commands/link/printDeprecationWarning.ts b/packages/cli/src/commands/link/printDeprecationWarning.ts index 3ff1c2c05..04dfb5a5c 100644 --- a/packages/cli/src/commands/link/printDeprecationWarning.ts +++ b/packages/cli/src/commands/link/printDeprecationWarning.ts @@ -3,9 +3,9 @@ import {logger} from '@react-native-community/cli-tools'; export default function printDeprecationWarning(command: string) { logger.warn( - `${chalk.bold( - `react-native ${command}`, - )} command is deprecated in favour of autolinking feature and it will be removed in the next major release. You can find more information about it in the documentation: ${chalk.bold( + `Calling ${chalk.bold( + command, + )} is deprecated in favour of autolinking feature and it will be removed in the next major release. You can find more information about it in the documentation: ${chalk.bold( 'https://github.com/react-native-community/cli/blob/master/docs/autolinking.md', )}`, ); diff --git a/packages/cli/src/commands/link/unlink.ts b/packages/cli/src/commands/link/unlink.ts index 8793d08b1..f6aef7252 100644 --- a/packages/cli/src/commands/link/unlink.ts +++ b/packages/cli/src/commands/link/unlink.ts @@ -30,7 +30,7 @@ const unlinkDependency = ( packageName: string, otherDependencies: Array, ) => { - printDeprecationWarning('unlink'); + printDeprecationWarning('react-native unlink [packageName]'); Object.keys(platforms || {}).forEach(platform => { const projectConfig: AndroidProjectConfig | IOSProjectConfig = project[platform]; From 646a582bdabe84fd400a481c93ed9717a3b29dcb Mon Sep 17 00:00:00 2001 From: Kacper Wiszczuk Date: Wed, 4 Mar 2020 22:32:02 +0100 Subject: [PATCH 3/4] Wrong English --- packages/cli/src/commands/link/printDeprecationWarning.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/commands/link/printDeprecationWarning.ts b/packages/cli/src/commands/link/printDeprecationWarning.ts index 04dfb5a5c..31a72799e 100644 --- a/packages/cli/src/commands/link/printDeprecationWarning.ts +++ b/packages/cli/src/commands/link/printDeprecationWarning.ts @@ -5,7 +5,7 @@ export default function printDeprecationWarning(command: string) { logger.warn( `Calling ${chalk.bold( command, - )} is deprecated in favour of autolinking feature and it will be removed in the next major release. You can find more information about it in the documentation: ${chalk.bold( + )} is deprecated in favor of autolinking feature and it will be removed in the next major release. You can find more information about it in the documentation: ${chalk.bold( 'https://github.com/react-native-community/cli/blob/master/docs/autolinking.md', )}`, ); From 1bd1327d378132097d69a9119dbf1f94113145f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Tue, 10 Mar 2020 18:07:16 +0100 Subject: [PATCH 4/4] adjust wording --- packages/cli/src/commands/link/__tests__/link.test.ts | 6 +++++- packages/cli/src/commands/link/printDeprecationWarning.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/commands/link/__tests__/link.test.ts b/packages/cli/src/commands/link/__tests__/link.test.ts index bcb7021cc..69817b746 100644 --- a/packages/cli/src/commands/link/__tests__/link.test.ts +++ b/packages/cli/src/commands/link/__tests__/link.test.ts @@ -1,7 +1,11 @@ import {func as link} from '../link'; import loadConfig from '../../../tools/config'; import makeHook from '../makeHook'; -jest.mock('chalk', () => ({grey: str => str, bold: str => str})); +jest.mock('chalk', () => ({ + grey: jest.fn(), + bold: jest.fn(), + dim: {underline: jest.fn()}, +})); jest.mock('../../../tools/config'); jest.mock('../makeHook', () => { return jest.fn(() => { diff --git a/packages/cli/src/commands/link/printDeprecationWarning.ts b/packages/cli/src/commands/link/printDeprecationWarning.ts index 31a72799e..74e980d2a 100644 --- a/packages/cli/src/commands/link/printDeprecationWarning.ts +++ b/packages/cli/src/commands/link/printDeprecationWarning.ts @@ -5,7 +5,7 @@ export default function printDeprecationWarning(command: string) { logger.warn( `Calling ${chalk.bold( command, - )} is deprecated in favor of autolinking feature and it will be removed in the next major release. You can find more information about it in the documentation: ${chalk.bold( + )} is deprecated in favor of autolinking. It will be removed in the next major release.\nAutolinking documentation: ${chalk.dim.underline( 'https://github.com/react-native-community/cli/blob/master/docs/autolinking.md', )}`, );