From c015d2a46ced82889ef8fb760b1915916a76388a Mon Sep 17 00:00:00 2001 From: Adam Miskiewicz Date: Mon, 8 Feb 2016 00:27:18 -0500 Subject: [PATCH] Update 'react-native upgrade' to warn when 'react' is not found in a project's dependencies when the react-native version is >= 0.21.0. --- local-cli/upgrade/upgrade.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/local-cli/upgrade/upgrade.js b/local-cli/upgrade/upgrade.js index 4038bc6aaee4f4..4ce70498453207 100644 --- a/local-cli/upgrade/upgrade.js +++ b/local-cli/upgrade/upgrade.js @@ -44,6 +44,19 @@ module.exports = function upgrade(args, config) { 'https://github.com/facebook/react-native/releases/tag/v' + semver.major(v) + '.' + semver.minor(v) + '.0' ) ); + + // >= v0.21.0, we require react to be a peer depdendency + if (semver.gte(v, '0.21.0') && !pak.dependencies['react']) { + console.log( + chalk.yellow( + '\nYour \'package.json\' file doesn\'t seem to have \'react\' as a dependency.\n' + + '\'react\' was changed from a dependency to a peer dependency in react-native v0.21.0.\n' + + 'Therefore, it\'s necessary to include \'react\' in your project\'s dependencies.\n' + + 'Just run \'npm install --save react\', then re-run \'react-native upgrade\'.\n' + ) + ); + return Promise.resolve(); + } } else { console.log( chalk.yellow(