From 962f843c68d53098f7c1ab48c2631a73c9045319 Mon Sep 17 00:00:00 2001 From: maciej simka Date: Thu, 18 Jul 2019 14:29:45 +0200 Subject: [PATCH 1/6] feat: install pods after upgrade Changed `installPods` helper to also accept argument determining whether `pod repo update` should be ran before `install` and refactored it slightly. Added calls to `installPods` in `upgrade` command to automatically update pods after applying patch and installing JS dependencies. Added warnings when patch was not successfully applied to remind users about running `pod install`. Updated snapshots. Resolves #212 --- packages/cli/src/commands/init/init.js | 2 +- .../upgrade/__tests__/upgrade.test.js | 124 +++++++++--------- packages/cli/src/commands/upgrade/upgrade.js | 27 ++++ packages/cli/src/tools/installPods.js | 46 ++++--- 4 files changed, 120 insertions(+), 79 deletions(-) diff --git a/packages/cli/src/commands/init/init.js b/packages/cli/src/commands/init/init.js index 35099c883..c1eda4ace 100644 --- a/packages/cli/src/commands/init/init.js +++ b/packages/cli/src/commands/init/init.js @@ -162,7 +162,7 @@ async function installDependencies({ }); if (process.platform === 'darwin') { - await installPods({projectName, loader}); + await installPods({projectName, loader, shouldUpdatePods: false}); } loader.succeed(); diff --git a/packages/cli/src/commands/upgrade/__tests__/upgrade.test.js b/packages/cli/src/commands/upgrade/__tests__/upgrade.test.js index af689b03e..5e7a5222c 100644 --- a/packages/cli/src/commands/upgrade/__tests__/upgrade.test.js +++ b/packages/cli/src/commands/upgrade/__tests__/upgrade.test.js @@ -174,6 +174,7 @@ test('fetches empty patch and installs deps', async () => { $ execa git add package.json $ execa git add yarn.lock $ execa git add package-lock.json + info Installing CocoaPods dependencies (this may take a few minutes) success Upgraded React Native to v0.58.4 πŸŽ‰. Now you can review and commit the changes" `); }, 60000); @@ -191,24 +192,25 @@ test('fetches regular patch, adds remote, applies patch, installs deps, removes opts, ); expect(flushOutput()).toMatchInlineSnapshot(` - "info Fetching diff between v0.57.8 and v0.58.4... - [fs] write tmp-upgrade-rn.patch - $ execa git rev-parse --show-prefix - $ execa git apply --binary --check tmp-upgrade-rn.patch --exclude=package.json -p2 --3way --directory= - info Applying diff... - $ execa git apply tmp-upgrade-rn.patch --exclude=package.json -p2 --3way --directory= - [fs] unlink tmp-upgrade-rn.patch - $ execa git status -s - info Installing \\"react-native@0.58.4\\" and its peer dependencies... - $ execa npm info react-native@0.58.4 peerDependencies --json - $ yarn add react-native@0.58.4 react@16.6.3 - $ execa git add package.json - $ execa git add yarn.lock - $ execa git add package-lock.json - info Running \\"git status\\" to check what changed... - $ execa git status - success Upgraded React Native to v0.58.4 πŸŽ‰. Now you can review and commit the changes" - `); + "info Fetching diff between v0.57.8 and v0.58.4... + [fs] write tmp-upgrade-rn.patch + $ execa git rev-parse --show-prefix + $ execa git apply --binary --check tmp-upgrade-rn.patch --exclude=package.json -p2 --3way --directory= + info Applying diff... + $ execa git apply tmp-upgrade-rn.patch --exclude=package.json -p2 --3way --directory= + [fs] unlink tmp-upgrade-rn.patch + $ execa git status -s + info Installing \\"react-native@0.58.4\\" and its peer dependencies... + $ execa npm info react-native@0.58.4 peerDependencies --json + $ yarn add react-native@0.58.4 react@16.6.3 + $ execa git add package.json + $ execa git add yarn.lock + $ execa git add package-lock.json + info Installing CocoaPods dependencies (this may take a few minutes) + info Running \\"git status\\" to check what changed... + $ execa git status + success Upgraded React Native to v0.58.4 πŸŽ‰. Now you can review and commit the changes" + `); expect( snapshotDiff(samplePatch, (fs.writeFileSync: any).mock.calls[0][1], { contextLines: 1, @@ -223,24 +225,25 @@ test('fetches regular patch, adds remote, applies patch, installs deps, removes const config = {...ctx, root: '/project/root/NestedApp'}; await upgrade.func([newVersion], config, opts); expect(flushOutput()).toMatchInlineSnapshot(` - "info Fetching diff between v0.57.8 and v0.58.4... - [fs] write tmp-upgrade-rn.patch - $ execa git rev-parse --show-prefix - $ execa git apply --binary --check tmp-upgrade-rn.patch --exclude=NestedApp/package.json -p2 --3way --directory=NestedApp/ - info Applying diff... - $ execa git apply tmp-upgrade-rn.patch --exclude=NestedApp/package.json -p2 --3way --directory=NestedApp/ - [fs] unlink tmp-upgrade-rn.patch - $ execa git status -s - info Installing \\"react-native@0.58.4\\" and its peer dependencies... - $ execa npm info react-native@0.58.4 peerDependencies --json - $ yarn add react-native@0.58.4 react@16.6.3 - $ execa git add package.json - $ execa git add yarn.lock - $ execa git add package-lock.json - info Running \\"git status\\" to check what changed... - $ execa git status - success Upgraded React Native to v0.58.4 πŸŽ‰. Now you can review and commit the changes" - `); + "info Fetching diff between v0.57.8 and v0.58.4... + [fs] write tmp-upgrade-rn.patch + $ execa git rev-parse --show-prefix + $ execa git apply --binary --check tmp-upgrade-rn.patch --exclude=NestedApp/package.json -p2 --3way --directory=NestedApp/ + info Applying diff... + $ execa git apply tmp-upgrade-rn.patch --exclude=NestedApp/package.json -p2 --3way --directory=NestedApp/ + [fs] unlink tmp-upgrade-rn.patch + $ execa git status -s + info Installing \\"react-native@0.58.4\\" and its peer dependencies... + $ execa npm info react-native@0.58.4 peerDependencies --json + $ yarn add react-native@0.58.4 react@16.6.3 + $ execa git add package.json + $ execa git add yarn.lock + $ execa git add package-lock.json + info Installing CocoaPods dependencies (this may take a few minutes) + info Running \\"git status\\" to check what changed... + $ execa git status + success Upgraded React Native to v0.58.4 πŸŽ‰. Now you can review and commit the changes" + `); }, 60000); test('cleans up if patching fails,', async () => { mockFetch(samplePatch, 200); @@ -271,30 +274,31 @@ test('cleans up if patching fails,', async () => { ); } expect(flushOutput()).toMatchInlineSnapshot(` - "info Fetching diff between v0.57.8 and v0.58.4... - [fs] write tmp-upgrade-rn.patch - $ execa git rev-parse --show-prefix - $ execa git apply --binary --check tmp-upgrade-rn.patch --exclude=package.json -p2 --3way --directory= - info Applying diff... - warn Excluding files that exist in the template, but not in your project: - - .flowconfig - error Excluding files that failed to apply the diff: - - ios/MyApp.xcodeproj/project.pbxproj - Please make sure to check the actual changes after the upgrade command is finished. - You can find them in our Upgrade Helper web app: https://react-native-community.github.io/upgrade-helper/?from=0.57.8&to=0.58.4 - $ execa git apply tmp-upgrade-rn.patch --exclude=package.json --exclude=.flowconfig --exclude=ios/MyApp.xcodeproj/project.pbxproj -p2 --3way --directory= - debug \\"git apply\\" failed. Error output: - error: .flowconfig: does not exist in index - error: ios/MyApp.xcodeproj/project.pbxproj: patch does not apply - error Automatically applying diff failed. We did our best to automatically upgrade as many files as possible - [fs] unlink tmp-upgrade-rn.patch - $ execa git status -s - error Patch failed to apply for unknown reason. Please fall back to manual way of upgrading - info You may find these resources helpful: - β€’ Release notes: https://github.com/facebook/react-native/releases/tag/v0.58.4 - β€’ Manual Upgrade Helper: https://react-native-community.github.io/upgrade-helper/?from=0.57.8&to=0.58.4 - β€’ Git diff: https://raw.githubusercontent.com/react-native-community/rn-diff-purge/diffs/diffs/0.57.8..0.58.4.diff" - `); + "info Fetching diff between v0.57.8 and v0.58.4... + [fs] write tmp-upgrade-rn.patch + $ execa git rev-parse --show-prefix + $ execa git apply --binary --check tmp-upgrade-rn.patch --exclude=package.json -p2 --3way --directory= + info Applying diff... + warn Excluding files that exist in the template, but not in your project: + - .flowconfig + error Excluding files that failed to apply the diff: + - ios/MyApp.xcodeproj/project.pbxproj + Please make sure to check the actual changes after the upgrade command is finished. + You can find them in our Upgrade Helper web app: https://react-native-community.github.io/upgrade-helper/?from=0.57.8&to=0.58.4 + $ execa git apply tmp-upgrade-rn.patch --exclude=package.json --exclude=.flowconfig --exclude=ios/MyApp.xcodeproj/project.pbxproj -p2 --3way --directory= + debug \\"git apply\\" failed. Error output: + error: .flowconfig: does not exist in index + error: ios/MyApp.xcodeproj/project.pbxproj: patch does not apply + error Automatically applying diff failed. We did our best to automatically upgrade as many files as possible + [fs] unlink tmp-upgrade-rn.patch + $ execa git status -s + error Patch failed to apply for unknown reason. Please fall back to manual way of upgrading + warn After resolving conflicts don't forget to change into \\"ios\\" directory and run \\"pod install\\" + info You may find these resources helpful: + β€’ Release notes: https://github.com/facebook/react-native/releases/tag/v0.58.4 + β€’ Manual Upgrade Helper: https://react-native-community.github.io/upgrade-helper/?from=0.57.8&to=0.58.4 + β€’ Git diff: https://raw.githubusercontent.com/react-native-community/rn-diff-purge/diffs/diffs/0.57.8..0.58.4.diff" + `); }, 60000); test('works with --name-ios and --name-android', async () => { mockFetch(samplePatch, 200); diff --git a/packages/cli/src/commands/upgrade/upgrade.js b/packages/cli/src/commands/upgrade/upgrade.js index b20b788e9..106d25a55 100644 --- a/packages/cli/src/commands/upgrade/upgrade.js +++ b/packages/cli/src/commands/upgrade/upgrade.js @@ -7,6 +7,7 @@ import execa from 'execa'; import type {ConfigT} from 'types'; import {logger, CLIError, fetch} from '@react-native-community/cli-tools'; import * as PackageManager from '../../tools/packageManager'; +import installPods from '../../tools/installPods'; import legacyUpgrade from './legacyUpgrade'; type FlagsT = { @@ -163,6 +164,20 @@ const installDeps = async (newVersion, projectDir) => { } }; +const installCocoaPodsDeps = async (projectDir, thirdPartyIOSDeps) => { + if (process.platform === 'darwin') { + logger.info( + `Installing CocoaPods dependencies ${chalk.dim( + '(this may take a few minutes)', + )}`, + ); + await installPods({ + projectName: projectDir.split('/').pop(), + shouldUpdatePods: thirdPartyIOSDeps.length > 0, + }); + } +}; + const applyPatch = async ( currentVersion: string, newVersion: string, @@ -265,6 +280,10 @@ async function upgrade(argv: Array, ctx: ConfigT, args: FlagsT) { projectDir, 'node_modules/react-native/package.json', )); + const thirdPartyIOSDeps = Object.values(ctx.dependencies).filter( + // $FlowFixMe + dependency => dependency.platforms.ios, + ); const newVersion = await getVersionToUpgradeTo( argv, @@ -285,6 +304,8 @@ async function upgrade(argv: Array, ctx: ConfigT, args: FlagsT) { if (patch === '') { logger.info('Diff has no changes to apply, proceeding further'); await installDeps(newVersion, projectDir); + await installCocoaPodsDeps(projectDir, thirdPartyIOSDeps); + logger.success( `Upgraded React Native to v${newVersion} πŸŽ‰. Now you can review and commit the changes`, ); @@ -319,6 +340,7 @@ async function upgrade(argv: Array, ctx: ConfigT, args: FlagsT) { } } else { await installDeps(newVersion, projectDir); + await installCocoaPodsDeps(projectDir, thirdPartyIOSDeps); logger.info('Running "git status" to check what changed...'); await execa('git', ['status'], {stdio: 'inherit'}); } @@ -328,6 +350,11 @@ async function upgrade(argv: Array, ctx: ConfigT, args: FlagsT) { 'Please run "git diff" to review the conflicts and resolve them', ); } + if (process.platform === 'darwin') { + logger.warn( + 'After resolving conflicts don\'t forget to change into "ios" directory and run "pod install"', + ); + } logger.info(`You may find these resources helpful: β€’ Release notes: ${chalk.underline.dim( `https://github.com/facebook/react-native/releases/tag/v${newVersion}`, diff --git a/packages/cli/src/tools/installPods.js b/packages/cli/src/tools/installPods.js index 159fb8370..6327ba29c 100644 --- a/packages/cli/src/tools/installPods.js +++ b/packages/cli/src/tools/installPods.js @@ -7,12 +7,35 @@ import inquirer from 'inquirer'; import {logger} from '@react-native-community/cli-tools'; import {NoopLoader} from './loader'; +async function updatePods(loader: typeof Ora) { + try { + loader.start( + `Updating CocoaPods repositories ${chalk.dim( + '(this may take a few minutes)', + )}`, + ); + await execa('pod', ['repo', 'update']); + } catch (error) { + // "pod" command outputs errors to stdout (at least some of them) + logger.log(error.stderr || error.stdout); + loader.fail(); + + throw new Error( + `Failed to update CocoaPods repositories for iOS project.\nPlease try again manually: "pod repo update".\nCocoaPods documentation: ${chalk.dim.underline( + 'https://cocoapods.org/', + )}`, + ); + } +} + async function installPods({ projectName, loader, + shouldUpdatePods, }: { projectName: string, loader?: typeof Ora, + shouldUpdatePods: boolean, }) { loader = loader || new NoopLoader(); try { @@ -77,27 +100,14 @@ async function installPods({ } } - try { - loader.start( - `Updating CocoaPods repositories ${chalk.dim( - '(this may take a few minutes)', - )}`, - ); - await execa('pod', ['repo', 'update']); - } catch (error) { - // "pod" command outputs errors to stdout (at least some of them) - logger.log(error.stderr || error.stdout); - loader.fail(); - - throw new Error( - `Failed to update CocoaPods repositories for iOS project.\nPlease try again manually: "pod repo update".\nCocoaPods documentation: ${chalk.dim.underline( - 'https://cocoapods.org/', - )}`, - ); - } + await updatePods(loader); } } + if (shouldUpdatePods) { + await updatePods(loader); + } + try { loader.succeed(); loader.start( From e57e84165be2fa4ab484b536090384c3c3c01a52 Mon Sep 17 00:00:00 2001 From: maciej simka Date: Fri, 19 Jul 2019 12:30:03 +0200 Subject: [PATCH 2/6] fix: revert indentation changes to snapshots --- .../upgrade/__tests__/upgrade.test.js | 124 +++++++++--------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/packages/cli/src/commands/upgrade/__tests__/upgrade.test.js b/packages/cli/src/commands/upgrade/__tests__/upgrade.test.js index 5e7a5222c..bc65d8819 100644 --- a/packages/cli/src/commands/upgrade/__tests__/upgrade.test.js +++ b/packages/cli/src/commands/upgrade/__tests__/upgrade.test.js @@ -192,24 +192,24 @@ test('fetches regular patch, adds remote, applies patch, installs deps, removes opts, ); expect(flushOutput()).toMatchInlineSnapshot(` - "info Fetching diff between v0.57.8 and v0.58.4... - [fs] write tmp-upgrade-rn.patch - $ execa git rev-parse --show-prefix - $ execa git apply --binary --check tmp-upgrade-rn.patch --exclude=package.json -p2 --3way --directory= - info Applying diff... - $ execa git apply tmp-upgrade-rn.patch --exclude=package.json -p2 --3way --directory= - [fs] unlink tmp-upgrade-rn.patch - $ execa git status -s - info Installing \\"react-native@0.58.4\\" and its peer dependencies... - $ execa npm info react-native@0.58.4 peerDependencies --json - $ yarn add react-native@0.58.4 react@16.6.3 - $ execa git add package.json - $ execa git add yarn.lock - $ execa git add package-lock.json - info Installing CocoaPods dependencies (this may take a few minutes) - info Running \\"git status\\" to check what changed... - $ execa git status - success Upgraded React Native to v0.58.4 πŸŽ‰. Now you can review and commit the changes" + "info Fetching diff between v0.57.8 and v0.58.4... + [fs] write tmp-upgrade-rn.patch + $ execa git rev-parse --show-prefix + $ execa git apply --binary --check tmp-upgrade-rn.patch --exclude=package.json -p2 --3way --directory= + info Applying diff... + $ execa git apply tmp-upgrade-rn.patch --exclude=package.json -p2 --3way --directory= + [fs] unlink tmp-upgrade-rn.patch + $ execa git status -s + info Installing \\"react-native@0.58.4\\" and its peer dependencies... + $ execa npm info react-native@0.58.4 peerDependencies --json + $ yarn add react-native@0.58.4 react@16.6.3 + $ execa git add package.json + $ execa git add yarn.lock + $ execa git add package-lock.json + info Installing CocoaPods dependencies (this may take a few minutes) + info Running \\"git status\\" to check what changed... + $ execa git status + success Upgraded React Native to v0.58.4 πŸŽ‰. Now you can review and commit the changes" `); expect( snapshotDiff(samplePatch, (fs.writeFileSync: any).mock.calls[0][1], { @@ -225,25 +225,25 @@ test('fetches regular patch, adds remote, applies patch, installs deps, removes const config = {...ctx, root: '/project/root/NestedApp'}; await upgrade.func([newVersion], config, opts); expect(flushOutput()).toMatchInlineSnapshot(` - "info Fetching diff between v0.57.8 and v0.58.4... - [fs] write tmp-upgrade-rn.patch - $ execa git rev-parse --show-prefix - $ execa git apply --binary --check tmp-upgrade-rn.patch --exclude=NestedApp/package.json -p2 --3way --directory=NestedApp/ - info Applying diff... - $ execa git apply tmp-upgrade-rn.patch --exclude=NestedApp/package.json -p2 --3way --directory=NestedApp/ - [fs] unlink tmp-upgrade-rn.patch - $ execa git status -s - info Installing \\"react-native@0.58.4\\" and its peer dependencies... - $ execa npm info react-native@0.58.4 peerDependencies --json - $ yarn add react-native@0.58.4 react@16.6.3 - $ execa git add package.json - $ execa git add yarn.lock - $ execa git add package-lock.json - info Installing CocoaPods dependencies (this may take a few minutes) - info Running \\"git status\\" to check what changed... - $ execa git status - success Upgraded React Native to v0.58.4 πŸŽ‰. Now you can review and commit the changes" - `); + "info Fetching diff between v0.57.8 and v0.58.4... + [fs] write tmp-upgrade-rn.patch + $ execa git rev-parse --show-prefix + $ execa git apply --binary --check tmp-upgrade-rn.patch --exclude=NestedApp/package.json -p2 --3way --directory=NestedApp/ + info Applying diff... + $ execa git apply tmp-upgrade-rn.patch --exclude=NestedApp/package.json -p2 --3way --directory=NestedApp/ + [fs] unlink tmp-upgrade-rn.patch + $ execa git status -s + info Installing \\"react-native@0.58.4\\" and its peer dependencies... + $ execa npm info react-native@0.58.4 peerDependencies --json + $ yarn add react-native@0.58.4 react@16.6.3 + $ execa git add package.json + $ execa git add yarn.lock + $ execa git add package-lock.json + info Installing CocoaPods dependencies (this may take a few minutes) + info Running \\"git status\\" to check what changed... + $ execa git status + success Upgraded React Native to v0.58.4 πŸŽ‰. Now you can review and commit the changes" + `); }, 60000); test('cleans up if patching fails,', async () => { mockFetch(samplePatch, 200); @@ -274,31 +274,31 @@ test('cleans up if patching fails,', async () => { ); } expect(flushOutput()).toMatchInlineSnapshot(` - "info Fetching diff between v0.57.8 and v0.58.4... - [fs] write tmp-upgrade-rn.patch - $ execa git rev-parse --show-prefix - $ execa git apply --binary --check tmp-upgrade-rn.patch --exclude=package.json -p2 --3way --directory= - info Applying diff... - warn Excluding files that exist in the template, but not in your project: - - .flowconfig - error Excluding files that failed to apply the diff: - - ios/MyApp.xcodeproj/project.pbxproj - Please make sure to check the actual changes after the upgrade command is finished. - You can find them in our Upgrade Helper web app: https://react-native-community.github.io/upgrade-helper/?from=0.57.8&to=0.58.4 - $ execa git apply tmp-upgrade-rn.patch --exclude=package.json --exclude=.flowconfig --exclude=ios/MyApp.xcodeproj/project.pbxproj -p2 --3way --directory= - debug \\"git apply\\" failed. Error output: - error: .flowconfig: does not exist in index - error: ios/MyApp.xcodeproj/project.pbxproj: patch does not apply - error Automatically applying diff failed. We did our best to automatically upgrade as many files as possible - [fs] unlink tmp-upgrade-rn.patch - $ execa git status -s - error Patch failed to apply for unknown reason. Please fall back to manual way of upgrading - warn After resolving conflicts don't forget to change into \\"ios\\" directory and run \\"pod install\\" - info You may find these resources helpful: - β€’ Release notes: https://github.com/facebook/react-native/releases/tag/v0.58.4 - β€’ Manual Upgrade Helper: https://react-native-community.github.io/upgrade-helper/?from=0.57.8&to=0.58.4 - β€’ Git diff: https://raw.githubusercontent.com/react-native-community/rn-diff-purge/diffs/diffs/0.57.8..0.58.4.diff" - `); + "info Fetching diff between v0.57.8 and v0.58.4... + [fs] write tmp-upgrade-rn.patch + $ execa git rev-parse --show-prefix + $ execa git apply --binary --check tmp-upgrade-rn.patch --exclude=package.json -p2 --3way --directory= + info Applying diff... + warn Excluding files that exist in the template, but not in your project: + - .flowconfig + error Excluding files that failed to apply the diff: + - ios/MyApp.xcodeproj/project.pbxproj + Please make sure to check the actual changes after the upgrade command is finished. + You can find them in our Upgrade Helper web app: https://react-native-community.github.io/upgrade-helper/?from=0.57.8&to=0.58.4 + $ execa git apply tmp-upgrade-rn.patch --exclude=package.json --exclude=.flowconfig --exclude=ios/MyApp.xcodeproj/project.pbxproj -p2 --3way --directory= + debug \\"git apply\\" failed. Error output: + error: .flowconfig: does not exist in index + error: ios/MyApp.xcodeproj/project.pbxproj: patch does not apply + error Automatically applying diff failed. We did our best to automatically upgrade as many files as possible + [fs] unlink tmp-upgrade-rn.patch + $ execa git status -s + error Patch failed to apply for unknown reason. Please fall back to manual way of upgrading + warn After resolving conflicts don't forget to change into \\"ios\\" directory and run \\"pod install\\" + info You may find these resources helpful: + β€’ Release notes: https://github.com/facebook/react-native/releases/tag/v0.58.4 + β€’ Manual Upgrade Helper: https://react-native-community.github.io/upgrade-helper/?from=0.57.8&to=0.58.4 + β€’ Git diff: https://raw.githubusercontent.com/react-native-community/rn-diff-purge/diffs/diffs/0.57.8..0.58.4.diff" + `); }, 60000); test('works with --name-ios and --name-android', async () => { mockFetch(samplePatch, 200); From 90edc60798187eeaea220d041bf42ed3496fdb57 Mon Sep 17 00:00:00 2001 From: maciej simka Date: Fri, 19 Jul 2019 12:58:05 +0200 Subject: [PATCH 3/6] fix: wrap `pod install` in try/catch block --- packages/cli/src/commands/upgrade/upgrade.js | 31 ++++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/packages/cli/src/commands/upgrade/upgrade.js b/packages/cli/src/commands/upgrade/upgrade.js index 106d25a55..7e7ef9d11 100644 --- a/packages/cli/src/commands/upgrade/upgrade.js +++ b/packages/cli/src/commands/upgrade/upgrade.js @@ -166,15 +166,28 @@ const installDeps = async (newVersion, projectDir) => { const installCocoaPodsDeps = async (projectDir, thirdPartyIOSDeps) => { if (process.platform === 'darwin') { - logger.info( - `Installing CocoaPods dependencies ${chalk.dim( - '(this may take a few minutes)', - )}`, - ); - await installPods({ - projectName: projectDir.split('/').pop(), - shouldUpdatePods: thirdPartyIOSDeps.length > 0, - }); + try { + logger.info( + `Installing CocoaPods dependencies ${chalk.dim( + '(this may take a few minutes)', + )}`, + ); + await installPods({ + projectName: projectDir.split('/').pop(), + shouldUpdatePods: thirdPartyIOSDeps.length > 0, + }); + } catch (error) { + if (error.stderr) { + logger.debug( + `"pod install" or "pod repo update" failed. Error output:\n${ + error.stderr + }`, + ); + } + logger.error( + 'Installation of CocoaPods dependencies failed. Try to install them manually by running "pod install" in "ios" directory after finishing upgrade', + ); + } } }; From 9388d74b082829eb25178c6c9118419ae668c5a1 Mon Sep 17 00:00:00 2001 From: Maciej Simka Date: Fri, 19 Jul 2019 13:06:17 +0200 Subject: [PATCH 4/6] fix: rephrase warning about manual pods installation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: MichaΕ‚ PierzchaΕ‚a --- packages/cli/src/commands/upgrade/upgrade.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/commands/upgrade/upgrade.js b/packages/cli/src/commands/upgrade/upgrade.js index 7e7ef9d11..3ace9cf60 100644 --- a/packages/cli/src/commands/upgrade/upgrade.js +++ b/packages/cli/src/commands/upgrade/upgrade.js @@ -365,7 +365,7 @@ async function upgrade(argv: Array, ctx: ConfigT, args: FlagsT) { } if (process.platform === 'darwin') { logger.warn( - 'After resolving conflicts don\'t forget to change into "ios" directory and run "pod install"', + 'After resolving conflicts don\'t forget to run "pod install" inside "ios" directory', ); } logger.info(`You may find these resources helpful: From 3832e0fdcd002187ff07ec1ef75299e6a0fcf310 Mon Sep 17 00:00:00 2001 From: maciej simka Date: Thu, 8 Aug 2019 14:21:52 +0200 Subject: [PATCH 5/6] chore: mock `process.platform` in tests --- packages/cli/src/commands/upgrade/__tests__/upgrade.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/cli/src/commands/upgrade/__tests__/upgrade.test.js b/packages/cli/src/commands/upgrade/__tests__/upgrade.test.js index bc65d8819..ac9d71d8c 100644 --- a/packages/cli/src/commands/upgrade/__tests__/upgrade.test.js +++ b/packages/cli/src/commands/upgrade/__tests__/upgrade.test.js @@ -107,6 +107,9 @@ beforeEach(() => { fs.unlinkSync = jest.fn((...args) => mockPushLog('[fs] unlink', args)); logs = []; (execa: any).mockImplementation(mockExecaDefault); + Object.defineProperty(process, 'platform', { + value: 'darwin', + }); }); afterEach(() => { From 5eb597563905f3f3489d5b880051a0422246bd93 Mon Sep 17 00:00:00 2001 From: maciej simka Date: Thu, 8 Aug 2019 14:28:47 +0200 Subject: [PATCH 6/6] fix: update snapshot --- packages/cli/src/commands/upgrade/__tests__/upgrade.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/commands/upgrade/__tests__/upgrade.test.js b/packages/cli/src/commands/upgrade/__tests__/upgrade.test.js index ac9d71d8c..c4ad3379e 100644 --- a/packages/cli/src/commands/upgrade/__tests__/upgrade.test.js +++ b/packages/cli/src/commands/upgrade/__tests__/upgrade.test.js @@ -296,7 +296,7 @@ test('cleans up if patching fails,', async () => { [fs] unlink tmp-upgrade-rn.patch $ execa git status -s error Patch failed to apply for unknown reason. Please fall back to manual way of upgrading - warn After resolving conflicts don't forget to change into \\"ios\\" directory and run \\"pod install\\" + warn After resolving conflicts don't forget to run \\"pod install\\" inside \\"ios\\" directory info You may find these resources helpful: β€’ Release notes: https://github.com/facebook/react-native/releases/tag/v0.58.4 β€’ Manual Upgrade Helper: https://react-native-community.github.io/upgrade-helper/?from=0.57.8&to=0.58.4